in reply to map question
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: map question (hash slice)
by AnomalousMonk (Archbishop) on Jul 29, 2019 at 13:38 UTC | |
by LanX (Saint) on Jul 29, 2019 at 14:30 UTC | |
|
Re^2: map question (hash slice)
by ikegami (Patriarch) on Jul 29, 2019 at 03:19 UTC | |
by LanX (Saint) on Jul 29, 2019 at 03:35 UTC | |
by ikegami (Patriarch) on Jul 29, 2019 at 05:51 UTC | |
by LanX (Saint) on Jul 30, 2019 at 12:21 UTC | |
by ikegami (Patriarch) on Jul 31, 2019 at 06:17 UTC | |
by LanX (Saint) on Jul 30, 2019 at 00:50 UTC |