Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Scalar Value Not Available To Subroutine

by LanX (Canon)
on Dec 20, 2012 at 19:06 UTC ( #1009777=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Scalar Value Not Available To Subroutine
in thread Scalar Value Not Available To Subroutine

> So loop "localisation" is different to the "localisation" done by local?

yes and no, since (unfortunately) you can't use local with lexicals!

But foreach tries to mimic this behaviour (a tribute to DWIM)

As you can see localization is as predicted with package vars, but seems to rebind the var to the new pad for lexical vars.

lanx@ubuntu:~$ perl our $i; for $i (1..9) { tst(); } sub tst { print $i; } 123456789 lanx@ubuntu:~$ perl my $i=42; for $i (1..9) { tst(); } sub tst { print $i; } 424242424242424242

we already had similar discussions.

Cheers Rolf


Comment on Re^3: Scalar Value Not Available To Subroutine
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2015-03-28 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:









    Results (627 votes), past polls