Please send questions to
st10@humboldt.edu .
#!/usr/bin/perl -w
# according to
# http://en.wikipedia.org/wiki/Scope_%28programming%29#Example
# "In the language Perl, variables can be defined with either static
# or dynamic scoping. Perl's keyword "my" defines a statically scoped
# local variable, while the keyword "local" defines a dynamically
# scoped local variable."
# adapting the static scoping example given:
print "static scoping demonstration\n";
$x = 133;
sub f
{
return $x;
}
sub g
{
my $x = 6; # my makes $x statically scoped
return f();
}
print "calling g: ".g()."\n";
print "calling f: ".f()."\n";