#!/usr/local/bin/perl #I am purposely not using strict and -w so that I can use undeclared variables print "Content-type: text/plain\n\n"; print "This file demonstrates the difference between my and local\n\n"; my $output = generate_page(); print $output; print "\nThis is the output of the program\n\n"; eval ("sub main {$output}"); main(); sub generate_page { my $output = <<'PAGE'; #!/usr/local/bin/perl #I am purposely not using strict and -w so that I can use undeclared variables fun1(); fun2(); fun3("Called from the main program"); sub fun1 { my $first = 25; fun3("Called from fun1"); return; } sub fun2 { local $first = 50; fun3("Called from fun2"); return; } sub fun3() { my ($msg) = @_; print "$msg: "; if (defined $first) { print "first is $first\n"; } else { print "first is undefined\n"; } return; } PAGE return $output; }