Skip to content

Instantly share code, notes, and snippets.

@onevcat
Created August 4, 2012 05:07
Show Gist options
  • Select an option

  • Save onevcat/3254692 to your computer and use it in GitHub Desktop.

Select an option

Save onevcat/3254692 to your computer and use it in GitHub Desktop.
Find and replace the email address in plain text with Perl
use Email::Find;
sub replaceEmail {
my $data = shift @_;
my $finder = Email::Find->new(
sub {
my($email, $orig_email) = @_;
my($address) = $email->format;
return qq|<a href="mailto:$address">$orig_email</a>|;
}
);
$finder->find(\$data);
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment