My advice is to NEVER put your email address on a webpage, because it is easy for evil search bots to scrape that type of data and use it for spam.
Here's a perl script I use to convert an email address into a snippet of javascript. You insert this javascript into your html page, and it will look like a "click here to email me" link, but if you view the source you'll just see obfuscated javascript code. It's not super secure, but should be enough to thwart most spam bots.
# script to obfuscate email addresses for web pages.
# just copy-n-paste the output into your web page
use strict;
my $email = 'first.last@mycompany.com'; # edit this line - your email
+goes here
print obfuscate_email($email), "\n";
sub obfuscate_email {
my $email = shift;
my $string = "<a href=\"mailto:" . $email . "\">" . $email . "</a>";
+
return obfuscate_text($string);
}
sub obfuscate_text {
my $string = shift;
$string =~ tr/[a-mn-zA-MN-Z]/[n-za-mN-ZA-M]/; # rot13
$string =~ s/@/@/g; # swap @ for the html
+ character code
$string =~ s/"/\\"/g; # escape doublequotes
$string =~ s/\./\056/g; # swap the dots with
+javascript . characters
my @charset = ('a'..'z','A'..'Z');
# randomize variable name - (3 char)
my $c = join '', @charset[rand @charset, rand @charset, rand @charse
+t];
my $result = "<script type=\"text/javascript\">document.write(\"$s
+tring\"." .
"replace(/[a-zA-Z]/g, function($c){return String.fromCharCode(($
+c<=\"Z\"?90:122)" .
">=($c=$c.charCodeAt(0)+13)?$c:$c-26);}));</script>";
return $result;
}
|