use strict; use warnings; my $foo = "Hello world!\n"; print $foo; &print_foo; print $foo; sub print_foo { print $foo; $foo = "Hello perlworld!\n"; }