Email::Address1 was a mis-type which I discovered when I tried to run the script. The reason why the two tripwire users are separate is that they aren't *real* users of the system but need to be weeded out anyway.
I was actually looking at that extra check and figured it was a bit redundant. Thanks, Mathew Adriano Ferreira wrote: > On 2/8/07, Mathew Snyder <[EMAIL PROTECTED]> wrote: >> 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); > > What's this Email::Address1 ? > >> 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; >> } >> } > > ids-tripwire and tripwire does not look like e-mail addresses, so you > should test them before using Email::Address (or $addr->user will not > be very useful, returning undef). Otherwise, something that looks like > a valid address doesn't need to be checked with m/[EMAIL PROTECTED]/ -- it > would > be equivalent to asking "if $addr->user" to make sure you have an > address that was successfully parsed. > >> >> 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/