in reply to Making a failed hash lookup return something other than undef
have I stumbled on the Best Solution to my problem?
No, actually your "solution" is not very good at all. Consider what will happen if $hash{'key'} is 0, undef, or an empty string. You should be using exists():
$hash{'key'} = "something" unless exists $hash{'key'};
I recall a node where BrowserUk John_M._Dlugosz suggested that exists() should return something more useful (like a reference to the element) in the case that the key did exist... but that wouldn't aid in the case where it doesn't.
-sauoq "My two cents aren't worth a dime.";
|
|---|