Are the following two snippets functionally equivalent? When I do it the first way, I get a bunch of use of uninitialized value
warnings because I try to evaluate the nonexistent $seen{$key}
. Hoping to avoid this. $seen{$key}
is always either 1 or undefined, it never takes on any other value throughout the script.
if($seen{$key}=='1'){
print "key already seen\n";
}else{
print "key not seen\n";
#do stuff with key
$seen{$key}='1';
}
~~~~
if(!$seen{$key}){
print "key not seen\n";
#do stuff with key
$seen{$key}='1';
}else{
print "key already seen\n";
}