in reply to Hash/Array slice : how to exclude items?
If this is only about the top-level items, I would create a shallow copy and delete the keys there (or only keep the "good" keys):
sub debug_hash( $hashref, $bad_keys = [qw[ schema logger ]] ) { my %output = %$hashref; delete @output{ @$bad_keys }; print Dumper \%output; } debug_hash( { logger => 'foo', payload => 'bar' } ); debug_hash( { schema => 'users', password => 'hunter2' }, ['schema', ' +password'] );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash/Array slice : how to exclude items?
by haukex (Archbishop) on Jan 24, 2023 at 14:40 UTC | |
by choroba (Cardinal) on Jan 24, 2023 at 16:30 UTC | |
by bliako (Abbot) on Jan 24, 2023 at 22:44 UTC | |
by hv (Prior) on Jan 24, 2023 at 23:15 UTC | |
by bliako (Abbot) on Jan 24, 2023 at 23:27 UTC | |
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 |