use Data::Dumper; use Data::Difference qw(data_diff); my @letters = qw( a a a b b b c c c ); my @word = qw( a a a b b); my @diff = data_diff( \@letters, \@word ); print Dumper( \@diff ); for (@diff) { print $_->{a} } __END__ $VAR1 = [ { 'a' => 'b', 'path' => [ 5 ] }, { 'a' => 'c', 'path' => [ 6 ] }, { 'a' => 'c', 'path' => [ 7 ] }, { 'a' => 'c', 'path' => [ 8 ] } ]; bccc
Update: "If you don't know the algorithm quickly, it's better to check out a module." (Karl Goethebier, PerlMustard)
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
In reply to Re: Subtracting one array from another (both have duplicate entries)
by karlgoethebier
in thread Subtracting one array from another (both have duplicate entries)
by dougbot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |