#!/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;
}