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


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

My experience in perl is going on about 3 weeks...so some of what you are saying is greek to me. Can you provide an example of how you would do it? The source file to pull the information from has the tag as follows:

showTollfree(1010)
// -->
'/script'
Fax:  (301)931-1285 
'br''a
href='mailto:KHargrove@servpro1010.com'>KHargrove@servpro1010.com'/a'

'/td'

I'm sorry to have to be wet nursed through this...but I have learned a ton of stuff over the last few weeks...I feel like my brain is going to explode!

  • Comment on Re^2: How to extract an email address from a mailto URL?

Replies are listed 'Best First'.
Re^3: How to extract an email address from a mailto URL?
by linuxer (Curate) on Dec 30, 2008 at 14:07 UTC

    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__
      Thanks, works great!