Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $x = 0;
- sub f { return $x; }
- sub g { my $x = 1; return f(); }
- print g()."\n";
- # the power of scoping compels you, change global $y!
- $y = 0;
- sub f1 { return $y; }
- sub g1 { local $y = 1; return f1(); }
- print g1()."\n";
- # $ perl ./scoping.pl
- # 0
- # 1
Add Comment
Please, Sign In to add comment