Guest User

Untitled

a guest
Jan 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. $x = 0;
  2. sub f { return $x; }
  3. sub g { my $x = 1; return f(); }
  4. print g()."\n";
  5.  
  6.  
  7. # the power of scoping compels you, change global $y!
  8. $y = 0;
  9. sub f1 { return $y; }
  10. sub g1 { local $y = 1; return f1(); }
  11. print g1()."\n";
  12.  
  13. # $ perl ./scoping.pl
  14. # 0
  15. # 1
Add Comment
Please, Sign In to add comment