in reply to Re^2: Hash/Array slice : how to exclude items?
in thread Hash/Array slice : how to exclude items?
delete local looks promising, thanks haukex and ikegami. If only delete returned the remaining hash. Shouldn't this work?: print Dumper(do { delete local @$hashref{ @$bad_keys }, $hashref} ); or this print Dumper(do { delete local @$hashref{ @$bad_keys }; $hashref} ); My intention is to delete the elements of the local hash, pass that to Dumper and hopefully leave it untouched when Dumper returns.
my @unwanted = qw( schema log ); my %hash = (schema=>1, log=>2, aa=>3); print Dumper(delete local @hash{ @unwanted }, \%hash); print Dumper(\%hash); $VAR1 = 1; $VAR2 = 2; $VAR3 = { 'aa' => 3 }; $VAR1 = { 'aa' => 3 };
my @unwanted = qw( schema log ); my %hash = (schema=>1, log=>2, aa=>3); print Dumper(do { delete local @hash{ @unwanted }; \%hash }); print Dumper(\%hash); $VAR1 = { 'aa' => 3, 'log' => 2, 'schema' => 1 }; $VAR1 = { 'aa' => 3, 'log' => 2, 'schema' => 1 };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Hash/Array slice : how to exclude items?
by hv (Prior) on Jan 24, 2023 at 23:15 UTC | |
by bliako (Abbot) on Jan 24, 2023 at 23:27 UTC | |
|
Re^4: Hash/Array slice : how to exclude items?
by LanX (Saint) on Jan 25, 2023 at 01:44 UTC | |
by bliako (Abbot) on Jan 25, 2023 at 09:01 UTC | |
by LanX (Saint) on Jan 25, 2023 at 14:26 UTC |