in reply to A cleaner way of scoping variables
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.
if ($foo) { print "true"; }
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/
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: A cleaner way of scoping variables
by KeighleHawk (Scribe) on Aug 10, 2004 at 23:43 UTC |
In Section
Seekers of Perl Wisdom