use warnings; use strict; my $foo = 1; printFoo (); my $foo = 2; printFoo (); sub printFoo { print "\$foo = $foo\n"; }