Perl-Sensitive Sunglasses | |
PerlMonks |
Re: What is it I don't understand about perl scoping?by youlose (Scribe) |
on Jul 09, 2009 at 12:05 UTC ( [id://778551]=note: print w/replies, xml ) | Need Help?? |
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 2as you wanted
In Section
Seekers of Perl Wisdom
|
|