in reply to testing a non-existant hash entry...how to handle
-Tonuse strict; my %hash; my $result; $hash{'foo'} = 0; $hash{'bar'} = undef; if ($hash{'foo'} && $hash{'bar'}) { $result = 'present'; } else { $result = 'NOT present'; } print "Direct checking thinks 'foo' and 'bar' are $result in \$hash.\n +"; if (defined($hash{'foo'}) && defined($hash{'bar'})) { $result = 'present'; } else { $result = 'NOT present'; } print "'defined' checking thinks 'foo' and 'bar' are $result in \$hash +.\n"; if (exists($hash{'foo'}) && exists($hash{'bar'})) { $result = 'present'; } else { $result = 'NOT present'; } print "'exists' checking thinks 'foo' and 'bar' are $result in \$hash. +\n";
|
|---|