Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: redeclaring variables with 'my'

by mirod (Canon)
on Nov 10, 2000 at 17:16 UTC ( [id://40928]=note: print w/replies, xml ) Need Help??


in reply to redeclaring variables with 'my'

I think you slightly mis-stated the common construct, it should be:

while( my $var= func( @args)) { # do something }

Otherwise the my $var returns undef which might not be what you want (the loop would not be executed).

As far as I know this is perfectly kosher. $var is declared, its scope is the inner block and I would bet (Perl guts Gurus can confirm this) that the whole thing is optimized so the variable is actually built (ie allocated) only once.

I'd be interested in knowing what are your local guru arguments.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-29 11:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found