At 07:18 PM 2/26/04 -0500, you wrote:
Hi Guys,

I have a problem with e-mail address's and an array. I have some code that
will be a documentation spider to go through all our technical
documentation, extract e-mail address's and attempt to sort and exclude
certain e-mails/patterns. All documentation is in plain text, so no filters,
etc are needed.

The first array will have every e-mail address found pushed into it.

The second array will be an "exclude" array, in which I would like to search
through, and remove from the "email" array, if found.

The following code will loop through the "email" array and the "exclude"
array, and successfully removes the emails from the "email" array that are
specified in the "exclude" array:

my %found = ();
foreach (@emails) { $found{$_}++ };
foreach (@exclude) { exists $found{$_} and delete $found{$_} }

BUT, if I print out the hash with this:
foreach my $key (keys %found) {
print "$key\n";
}

The output comes up messed up for example:
chris.com

instead of:
[EMAIL PROTECTED]

Why is this happening? Also, if I wanted to add for example: info without
@domain.xxx to the "exclude" array, how can I remove any e-mail in the
"emails" array based on a partial match?

Thanks so much!
-c

I'd be inclined to turn your exclude array into a hash before and test for existence against it as you're building your email array, i.e. if you get a regex to find an email address on the current line, check for existence of $exclude{$1} or whatever the regex param happens to be, before you push it onto the emails array. Based on your output, you should examine the elements of @emails. I'd guess you're regex isn't escaping the '@'.



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to