I know that the answer has already been accepted, but I decided it was worth explaining why the program acted in this way in the first place.
A hash is not created until the second line of the Init
function ( $Hash->{Key}=10
), which automatically creates a hash and stores the link in the $Hash
scanner. This scalar is local to the function and has nothing to do with the $Hash
variable in the body of the script.
This can be changed by changing the way the Init
function processes its arguments:
sub Init { my $Hash = $_[0] = {}; $Hash->{'Key'} = 10; }
source share