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.

Thanks,
Mathew

There's no reason to try and fit it all in a single line, at least not
until you figure out how to make it work. You haven't told us whether
you want to skip the names that are in the hash, or the ones that
aren't in the hash, but you can work out the details for you case. The
following should get you started, though. For the sake of argument,
we'll assume the emails from the web page are stored in '@web_emails'
and we're skipping users whose names appear in %users.

   my @keepers;
   while (@web_emails) {
       next unless pop(@web_emails) =~ /^(.*?)@/;
       next if exists $users{$1};
       push @keepers, $1;
   }

If you really wanted, you could combine that into something shorter
and less readable like

   push @keepers, $1 if pop(@web_emails) =~ /^(.*?)@/ and !defined $users{$1};

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to