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 dynamic scoping example given:

print "dynamic scoping demonstration\n";

$x = 133;

sub f 
{ 
    return $x; 
}

sub g 
{ 
    local $x = 6;    # local makes $x dynamically scoped
    return f(); 
}

print "calling g: ".g()."\n";
print "calling f: ".f()."\n";