See inline comment:

> -----Original Message-----
> From: Nikola Janceski [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 21, 2002 8:58 AM
> To: 'Priss'; [EMAIL PROTECTED]
> Subject: RE: Remove elements in an array from a different array
> 
> 
> use hashes.
> 
> my %HASH;
> $HASH{$_}++ foreach @arr1;
> delete $HASH{$_} foreach @arr2;
> 
> @arr1 = keys %HASH;

To preserve the order change the above line to:
@arr1 = grep $HASH{$_}, @arr1;

> 
> @arr1 now has ( one three five );
> 
> > -----Original Message-----
> > From: Priss [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, August 21, 2002 8:54 AM
> > To: [EMAIL PROTECTED]
> > Subject: Remove elements in an array from a different array
> > 
> > 
> > Hello,
> > 
> > I am very new to Perl, wonder if someone can help me
> > with this... if I have:
> > 
> > @arr1 = qw (one two three four five);
> > @arr2 = qw (two four);
> > 
> > How can I remove all elements from @arr2 from @arr1 so
> > the new array will be @newarr = (one three five)?? 
> > 
> > Many thanks.
> > 
> > Priss
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Everything you'll ever need on one web page
> > from News and Sport to Email and Music Charts
> > http://uk.my.yahoo.com
> > 
> > -- 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> 
> --------------------------------------------------------------
> --------------
> --------------------
> The views and opinions expressed in this email message are 
> the sender's
> own, and do not necessarily represent the views and opinions of Summit
> Systems Inc.
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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

Reply via email to