in reply to Truthfulness of references
The other answers have given you some good background information, but just to fill you in with what you need:
sub return_ref { return if rand < 0.3; my %hash; $hash{foo} = 'bar' if rand < 0.5; return \%hash; } my $ref = return_ref(); if (ref($ref) eq 'HASH' and %$ref) { print "We have a non-empty hash reference.\n"; } else { print "No hash reference, or empty hashref.\n"; }
Run that a couple of times and observe the behaviour.
• another intruder with the mooring in the heart of the Perl
|
|---|