use warnings; my $s = "s1"; print "define var: $s\n"; &test; sub test{ print "sub: $s\n"; } my $s = "s1-2nd"; print "define var: $s\n"; &test;