in reply to What is it I don't understand about perl scoping?

use strict;

my $foo = 1;
my $fum = 1;

print STDERR "variables are now: $foo $fum\n";

{
    my $foo = 2;
    $fum = 2;
    &foo();
    print STDERR "variables are now: $foo $fum\n";

}

sub foo {
    print STDERR "variables are now: $foo $fum\n";

}



Resulting:
variables are now: 1 1
variables are now: 1 2
variables are now: 2 2
as you wanted
  • Comment on Re: What is it I don't understand about perl scoping?