$hash->{'a'} = 1; $hash->{'b'} = undef; $hash->{'c'} = undef; $hash->{'d'} = undef; if (scalar grep {defined} values %{$hash} == 0) { print "empty\n"; } $hash->{'a'} = undef; $hash->{'b'} = undef; $hash->{'c'} = undef; $hash->{'d'} = undef; if (scalar grep {defined} values %{$hash} == 0) { print "empty\n"; }
In reply to Re: Re: hash problem
by Anonymous Monk
in thread One liner to Check and undef hash elements
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |