Ahhh, the famous 'map' function - haven't tried it, so I guess it's about
time to give it a try. I wasn't too familiar with 'exists' either...thanks
for the advice.

-----
Scot Robnett



-----Original Message-----
From: Bob Showalter [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 2:23 PM
To: 'Scot Robnett'; [EMAIL PROTECTED]
Subject: RE: Replacing/deleting text in a text file, part deux


Scot Robnett wrote:
> Anything I can do to make this an easier question? No
> responses...maybe I didn't ask the question the right way or made it
> confusing as to what I am trying to do? Would it help to split it up?
> Thanks for any advice...
>
> ...
> foreach $record(sort(@records)) {
>  chomp($record);
>  ($comp,$addr) = split(/\|/, $record);
>   @emails = split /:/, $addr;
>
> # Right here, I want to see if any of the addresses
> # in @addresses match an address in @emails for this # particular
> $record.

Turn @addresses into a hash (do this ouside the loop of course):

   my %addresses = map ($_, 1), @addresses;

Then, to remove entries in @emails that exist in @addresses:

   @emails = grep !exists($addresses{$_}), @emails;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to