in reply to Re: Checking and undef'in hash elements in one step?
in thread One liner to Check and undef hash elements
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
|
|---|