in reply to Delete a zero-valued hash element

and nor would I expect it to.

Given the following code:

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;
I get the following results:
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?


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg