![]() |
|
"be consistent" | |
PerlMonks |
Re^3: capture vars undefby Chady (Priest) |
on Jul 28, 2004 at 06:20 UTC ( #377937=note: print w/replies, xml ) | Need Help?? |
They haven't gone out of scope. Here's an attempt at explaining that: In the first example, you have two if blocks, the first if block provides a new scope for the second block, so what you have is something like this:
Note that one if block will not kill the $<digit> vars, but once the inner block finishes, then its variables are destroyed, and you get the outer block's $<digit>s Here's an example that might explain it better:
This will print aa cc and not your expected bb dd in the outer block. Update: here's another way to think of it:
He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life. Chady | http://chady.net/
In Section
Seekers of Perl Wisdom
|
|