P is for Practical | |
PerlMonks |
Re: Hash/Array slice : how to exclude items?by LanX (Saint) |
on Jan 24, 2023 at 14:15 UTC ( [id://11149821]=note: print w/replies, xml ) | Need Help?? |
I suppose that you know that %hash{...} is a new slice syntax that returns the keys too, and that's your intention. Regarding your syntax > %hash{-'schema', -'log'} Well "-" has a meaning in arrays, so I'd rather prefer something else like "!" But this would get messy if the list also included non-negated elements, %hash{'schema', -'log'} # WHAT??? so for the sake of a clean design one would rather do only one negation %hash{! 'schema', 'log'} I'm not aware of a built-in syntax to do this, but it's basically syntactic sugar for a grep, see demo in debugger
I know you didn't want grep, but this offers many flexibilities, like dynamically deciding what to exclude.
Cheers Rolf °) the +{...} is just an anonymous hash for pairwise dump
In Section
Seekers of Perl Wisdom
|
|