perl -wMstrict -le "my @arr1 = qw(one two three four five); my @arr2 = qw(one a b one c d e two f g h two i j two); my %seen1 = map { $_ => 0 } @arr1; @arr2 = grep { ! exists $seen1{$_} or ! $seen1{$_}++ } @arr2; print qq(@arr2); " one a b c d e two f g h i j
In reply to Re: Comparing arrays in perl.
by Anonymous Monk
in thread Comparing arrays in perl.
by anand_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |