Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Refactoring Perl #6 - Split Temporary Variable

by pKai (Priest)
on Aug 16, 2007 at 18:52 UTC ( #633155=note: print w/replies, xml ) Need Help??

in reply to Refactoring Perl #6 - Split Temporary Variable

Regarding your for $i "possible exception" example:

If one thinks the variable can be used after the loop, containing something sensible set inside the loop, you will be bitten by perl which will arrange to have made your variable "implicitly local to the loop and regains its former value upon exiting the loop." (c/f perldoc perlsyn)

Replies are listed 'Best First'.
Re^2: Refactoring Perl #6 - Split Temporary Variable
by agianni (Hermit) on Aug 16, 2007 at 20:19 UTC

    Yeah, now that I think of it, in PBP , TheDamian suggests:

    Always declare a for loop iterator variable with my. (p. 108)

    for just that reason. As such, I think re-use of temporary variables in Perl should be limited only to accumulators.

    perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://633155]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2021-04-17 05:49 GMT
Find Nodes?
    Voting Booth?

    No recent polls found