But you might be interested in another approach using hash-slices, which is way faster for big data.
use strict; use warnings; my @got = qw(blue_shirt hat jacket preserver ); # sunscreen); my @required = qw(preserver sunscreen water_bottle jacket); # ---------- directly coded my %required; @required{@required}=@required; delete @required{@got}; warn "Skipper is missing: ", values %required; # ---------- or alternative as custom function warn "Skipper is missing: ", array_minus(@got,@required); sub array_minus (\@\@) { my ( $got, $required ) = @_; my %required; @required{@required}=@required; delete @required{@got}; return values %required; }
Skipper is missing: water_bottle sunscreen at d:/exp/hash_diff.pl l +ine 14. Skipper is missing: sunscreen water_bottle at d:/exp/hash_diff.pl l +ine 28.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
In reply to Re: map question (hash slice)
by LanX
in thread map question
by catfish1116
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |