TMTOWTDI (couldn't figure out how to do this with just an "or" or an "and")
use strict; use warnings; use Data::Dumper; my $hash; $hash->{'a'} = 1; $hash->{'b'} = undef; $hash->{'c'} = undef; $hash->{'d'} = undef; unless (grep {defined $$hash{$_} xor $$hash{$_}=undef} keys %{$hash} ) + { print "empty\n";} else { print "Not empty\n"; } print Dumper \$hash;
-enlil
In reply to Re: Re: Checking and undef'in hash elements in one step?
by Enlil
in thread One liner to Check and undef hash elements
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |