Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Consise way to filter out keys with undef values from a hash slice?

by choroba (Cardinal)
on Jun 01, 2020 at 20:21 UTC ( [id://11117570]=note: print w/replies, xml ) Need Help??


in reply to Consise way to filter out keys with undef values from a hash slice?

What about grepping the keys even before the undef values are created?
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %args = (profile => 'foo'); my %ta = %args{ grep exists $args{$_}, qw( profile user password ) }; print Dumper \%ta;
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11117570]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-19 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found