Does this look like it *should* work? while ($data->get_tag("small")) { my $email = $data->get_trimmed_text("/small"); my $addr = new Email::Address1(undef, $email); my $addrUser = $addr->user; if ($email =~ m/^ids-tripwire/gmx or $email =~ m/^tripwire/gmx or exists($userID{$addrUser})) { next; } else { push @emails, $email if $email =~ m/[EMAIL PROTECTED]/gmx; } }
I have filled the %userID hash with the usernames of people that are authorized to use the system I'm writing this script for (usernames match user portion of email addresses). What it is doing is extracting email addresses from a webpage returned by HTML::TokeParser and WWW::Mechanize. What I am expecting it to do is pull the user portion of each email address extracted, compare it to my hash of user IDs and move on to the next if it is found. Is that what you see? On an unrelated note, will the regexes that I use for ids-tripwire and tripwire work as they are or do I need to put the '@domain.com' portion in too? The domain will never change and I only need to worry about those two addresses outside of the users. Adriano Ferreira wrote: > On 2/2/07, Mathew Snyder <[EMAIL PROTECTED]> wrote: >> I have a script which extracts email addresses from a web page, pushes >> them into >> an array and then prints them out before asking if I wish to perform >> the work on >> them that is required. >> >> What I would like to do is compare the username portion of the email >> address to >> a list of usernames in a hash to determine if the email address should be >> skipped. I just don't know how to write out the regex for that. The >> line I >> have so far is >> push @emails, $email if $email =~ m/[EMAIL PROTECTED]/gmx unless ($email =~ >> m/^ >> >> I don't know how to further this to accomplish what I need. Can >> someone please >> help. > > Be lazy. Use Email::Address to take care of the parsing of the e-mail > addresses and many subtleties in the specification you even didn't > want to know about. > > use Email::Address; > my $addr = Email::Address->new(undef, '[EMAIL PROTECTED]'); > my $user = $addr->user; # this is "casey" > > Regards, > Adriano Ferreira. > >> >> Thanks, >> Mathew >> >> -- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> http://learn.perl.org/ >> >> >> > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/