Reputation: 3391
Why does this print 8
? Why doesn't $e
alter $i
?
my $i = 8;
sub u
{
return \$i;
}
my $e = u();
$e = "eer";
print $i; #8
Upvotes: 1
Views: 80
Reputation: 62109
References are not aliases. You must explicitly dereference them.
$$e = "eer"; # Store 'eer' into the variable referenced by $e
is not the same as
$e = 'eer'; # Store 'eer' into $e, discarding its previous content
Upvotes: 8