![]() |
|
Do you know where your variables are? | |
PerlMonks |
Re: A cleaner way of scoping variablesby Chady (Priest) |
on Aug 09, 2004 at 13:26 UTC ( #381218=note: print w/replies, xml ) | Need Help?? |
If $bar is temporary, and your main worry is about ending up declaring a lot of globals for temporary usage, then consider changing your code. I know that your example is simplified for the sake of posting, but nevertheless, in your example you can throw away $bar completely.
But if you want to use the value a little farther below it probably means that you need that variable, and hence you should declare it, or maybe you should group together the parts of code that are working on the same temporary variable so that you can scope tightly. just my 2 cents. 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
|
|