in reply to Default Values in Subroutines

You can also use exists to distinguish whether hash entries exist. If you don't set a default and the caller does not provide a value, then the entry will not exist.

The following code:

#!/usr/bin/perl use strict; use warnings; my %hash = ( a => 1, b => undef); foreach my $key ('a', 'b', 'c') { print "$key " . (defined($hash{$key})?"is":"is not") . " defin +ed\n"; print "$key " . (exists($hash{$key})?"does":"does not") . " ex +ist\n"; }

produces the following output:

a is defined a does exist b is not defined b does exist c is not defined c does not exist