Putting aside the question of what an "undefined hash" might be, what you might do is return undef on failure and a reference to a hash if all goes well. Aside from being easier to deal with, this will be more efficient since the hash contents won't get flattened into a LIST and copied back into the destination hash.
sub getHash { ... if( $hunky_dory ) { return \%ret_value; } else { return undef } } my $hash_ref = getHash( ); unless( defined $hash_ref ) { die "Woe is me\n"; } # ... get on with it ...
In reply to Re: How to have a subroutine return an undefined hash
by Fletch
in thread How to have a subroutine return an undefined hash
by loris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |