>use hashes.

>my %HASH;
>$HASH{$_}++ foreach @arr1;
>delete $HASH{$_} foreach @arr2;

>@arr1 = keys %HASH;

> @arr1 now has ( one three five );

Perhaps If you want to maintain the order in the array, you might use it this way:

my %HASH;
my %hORD;
my $count = 0;
$HASH{$_} = ($count++)  for @arr1;
delete $HASH{$_} for @arr2;
%hORD = reverse %HASH;
@arr1 = ();
push(@arr1,$hORD{$_}) for sort { $a <=> $b } keys %hORD;






> -----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]


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

Reply via email to