http://www.perlmonks.org?node_id=733247


in reply to Re^2: How to extract an email address from a mailto URL?
in thread How to extract an email address from a mailto URL?

Well, first install these two modules (and their unresolved dependencies if there are any):

Then you can do something like this (Quickshot, untested):

#!/usr/bin/perl use strict; use warnings; use Regexp::Common qw(Email::Address); use Email::Address; my $filename = 'file_to_parse.dat'; open my $rh, '<', $filename or die "$filename: $!"; # Requirement: href=, mailto: and the mailaddress must be in the same +line! my @addresses = map { m/mailto:($RE{Email}{Address})/o; $1 } grep { m/href=.+?mailto:/ } <$rh> ; close $rh; { local $, = local $\ = "\n"; print @addresses; } __END__