Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
This
> grep { $args{$_ } } keys %ta; Will also delete all false values like 0 or "" . You rather want to test on definedness and not truth This keys on a slice > keys %args{'profile', 'user', 'password'}; Is over complicated and doesn't make sense. You obviously just want the list of keys directly 'profile', 'user', 'password' But I concur with choroba that using exists right from the beginning is the cleanest way, since undef could be a legal value.
editThere is - unfortunately - no "slice when exists" operator in Perl. Otherwise (ab)using hashes for set operations like intersections would be trivial.
Cheers Rolf In reply to Re: Consise way to filter out keys with undef values from a hash slice?
by LanX
|
|