sub by_val { my ($foo) = @_; print "Foo = $foo\n"; $foo = 10; # only 'foo' belonging to this sub is modified } sub by_ref { my ($foo_ref) = @_; print "Foo = $$foo_ref\n"; # pring value in 'bar' $$foo_ref = 10; # will modify 'bar' } my $bar = 5; by_val($bar); print "bar = $bar\n"; by_ref(\$bar); # $bar may no be modified inside the sub. print "bar = $bar\n";