Jerry Preston wrote: > > Hi!, Hello,
> I know that this is a no brainer, but I cannot not get it! I want to > compare two arrays and delete the same values in one array. > > foreach $j ( @a1 ) { > foreach $p ( @a2 ) { > $a2[ $p ] = undef if $a1[ $j ] == $a2 $p ]; > } > } > > What is wrong and is there a better, PERL way to do this? No, but there is a Perl way to do it: :-) @a2 = do { my %seen; @seen{ @a1 } = ( 1 ) x @a1; grep !$seen{ $_ }, @a2; }; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>