I'm working with hashes in perl, but don't understand why the hash value changes in the following:
use strict;
sub test
{
my ($value_ref) = @_;
my %value = %$value_ref;
$value{'abc'}{'xyz'} = 1;
}
my %hash;
$hash{'abc'}{'xyz'} = 0;
test (\%hash);
print "$hash{'abc'}{'xyz'}\n";
The above returns 1, why doesn't it return 0 like this it does here?
use strict;
sub test
{
my ($value_ref) = @_;
my %value = %$value_ref;
$value{'abc'} = 1;
}
my %hash;
$hash{'abc'} = 0;
test (\%hash);
print "$hash{'abc'}\n";
I imagine it has to do with how I'm passing in %hash. What am I missing?