use strict; use warnings; sub foo{ my $a = 1; print "$a\n"; bar(\$a); print "$a\n"; } sub bar{ my $b = shift; $$b = 2; } foo;