... filter out undefined values ... [emphasis added]
My take is that keys with undefined values (either because non-existent or undef) are to be filtered out. One way:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my %args = ('profile' => 'foo', 'xyzzy' => undef, 'status' => 0); my %ta = map { defined $args{$_} ? ($_ => $args{$_}) : () } qw(profile password xyzzy status) ; dd 'filtered', \%ta; dd 'original', \%args; " ("filtered", { profile => "foo", status => 0 }) ("original", { profile => "foo", status => 0, xyzzy => undef })
Give a man a fish: <%-{-{-{-<
In reply to Re: Consise way to filter out keys with undef values from a hash slice?
by AnomalousMonk
in thread Consise way to filter out keys with undef values from a hash slice?
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |