and nor would I expect it to.
Given the following code:
I get the following results:my %hash=( foo=> 1, bar => 2, fazz=> 0 ); my $rc = delete $hash{bar}; printf "%s\n",$rc; $rc = delete $hash{fazz}; printf "%s\n",$rc;
2 0
If you read the perldoc for the delete function you'll notice:
Returns a list with the same number of elements as the number
of elements for which deletion was attempted. Each element of
that list consists of either the value of the element deleted,
or the undefined value. In scalar context, this means that you
get the value of the last element deleted (or the undefined
value if that element did not exist).
So.. if your value for the key is zero anyway then you'll just return a zero in the scalar context.
Clear as mud?
In reply to Re: Delete a zero-valued hash element
by blue_cowdawg
in thread Delete a zero-valued hash element
by sush
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |