Forgot your password?
typodupeerror

Comment Encode your email addresses (Score 1) 310

I'm certain most slashdot readers can wipped up there own (and there is probably a better way), but here is a quick script which will HTML encode all the email addresses in a file.

#!/usr/local/bin/perl -pi.bak

while( m/(\@|\&\#0?64;)([\w-\.]+)(\.|\&\#0?46;)(com|org|n et|gov)/ ){
my $x = encode($2);
my $y = encode($4);
s/(\@|\&\#0?64;)([\w-\.]+)(\.|\&\#0?46;)(com|org|n et|gov)/\&\#064;$x\&\#046;$y /;
}

sub encode {
my $str = shift;
my @str = split( //, $str );

foreach my $c (@str){
$c = sprintf( "\&\#%03d\;", ord($c));
}

return join('', @str);
}

Slashdot Top Deals

It isn't easy being the parent of a six-year-old. However, it's a pretty small price to pay for having somebody around the house who understands computers.

Working...