use strict; use warnings; main(); # <----- change here sub main { # <----- change here my $foo = 5; print "Content-type: text/plain\n"; print "Content-disposition: inline; filename=foo.txt\n\n"; printf "Package: %s\n", __PACKAGE__; printf "[%s] Before: %s\n", $$, $foo; badness(5); printf "[%s] After: %s\n", $$, $foo; } # <----- change here sub badness { my $val = shift; printf "[%s] badness: %s\n", $$, $foo; $foo += $val; }