<?php
function perl_rfc822 ($email) {
  
//@see http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
  
  
$regex='http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html';
  
  if (
file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.basename($regex))) {
    
$regex=dirname(__FILE__).DIRECTORY_SEPARATOR.basename($regex);
  }

  
$regex=file_get_contents($regex);
  
  
$regex=preg_replace('#.*?<pre>\s+(.+?)\s+</pre>.*#is','$1',$regex);
  
  
$regex=htmlspecialchars_decode($regex);

  
$regex=preg_replace('/[\r\n]+/s','',$regex);
  
  
//comments stripped and replaced with whitespace
  
$email=preg_replace('/\(.*\)/',' ',$email);
  
  return 
preg_match("/$regex/D"$email);  
}