- or download this
If we apply operation X to a variable of type Y,
we get a variable of type Z.
- or download this
X(Y) : Z
- or download this
$GLOBAL = "static";
$LOCAL = "dynamic";
...
}
global_scope();
- or download this
global scope: static,dynamic,lexical
evaluation context: static,dynamic,lexical
- or download this
sub local_scope {
local ($LOCAL) = "-------";
...
print "\n";
print "but outside local_scope(), we still have:\n";
show_evaluation_context();
- or download this
local scope: static,-------,lexical
evaluation context: static,-------,lexical
but outside local_scope(), we still have:
evaluation context: static,dynamic,lexical
- or download this
sub lexical_scope {
my ($LEXICAL) = "-------";
...
local_override();
print "\n";
lexical_scope();
- or download this
lexical scope: static,dynamic,-------
evaluation context: static,dynamic,DYNAMICALLY RE-BOUND VALUE
lexical scope: static,dynamic,-------
evaluation context: static,dynamic,lexical
- or download this
package Foo;
...
print $Foo::VAR1, "\n";
print $VAR1, "\n";
print $VAR2, "\n";
- or download this
VAR1 in package 'Foo'.
VAR1 in package 'main'.
VAR2 in package 'main'.
- or download this
my $total = 0;
for $i (1..10) {
$total += $i;
}
print $total, "\n";
- or download this
sub sum_of {
my ($item, @list) = @_;
return ((defined $item) ? $item + sum_of (@list) : 0);
}
print sum_of (1..10), "\n";