in reply to Re^2: Scope of $/
in thread Scope of $/
I guess you can think of a local var as sort of like creating a stack of that variable. The local statement is like a "push" and when you exit the scope of the local, that is like a "pop". Rough analogy, but that is descriptive of the behavior.
#!usr/bin/perl use warnings; use strict; our $x = 1; #a package variable { print "$x\n"; #prints 1 local $x = 99; print "$x\n"; #prints 99 } print "$x\n"; #prints 1, back to before the "local"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Scope of $/
by Anonymous Monk on May 26, 2016 at 01:52 UTC | |
by Marshall (Canon) on May 26, 2016 at 01:55 UTC | |
by NetWallah (Canon) on May 26, 2016 at 05:51 UTC | |
by Laurent_R (Canon) on May 26, 2016 at 08:52 UTC |