On Thu, 6 Oct 2016 22:20:51 +0100 Sam Kington <sam@illuminated.co.uk> wrote: > Or turn to the CPAN and use the defensive programming from above: > > use Hash::MoreUtils qw(slice_def); > do_thing( > %{ > slice_def( > { > thing => $thing, > this => $this // undef, > that => get_that_maybe() // undef, > } > ) > } > ); It's not *particularly* neat syntax, but if it helps 'pairgrep' from List::Util has been around for a while now (and backports on CPAN work to earlier perls): do_thing( pairgrep { defined $_->value } thing => $thing, this => $this // undef, that => get_that_maybe() // undef, ) Could always be neatened with sub definedvals { pairgrep { $_->value } @_ } -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous | Thread Next