in reply to Shortcut operator for $a->{'b'}=$b if $b;
No really swift code I can think of, which prevents the keys from being inserted. But if you can allow empty keys to exist briefly, you can audit them afterwards:
Of course, that's just shifting the ugliness.$a = { d=>1, e=>2, f=>3, g=>undef, h=>0, i=>4 }; delete @$a{ grep { not $a->{$_} } keys %$a };
--
[ e d @ h a l l e y . c c ]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Shortcut operator for $a->{'b'}=$b if $b;
by radiantmatrix (Parson) on Sep 20, 2005 at 17:35 UTC |
In Section
Seekers of Perl Wisdom