Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Scalar Value Not Available To Subroutine

by ikegami (Pope)
on Dec 21, 2012 at 05:41 UTC ( #1009865=note: print w/replies, xml ) Need Help??


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

Effectively, the loop variable has no relationship with any pre-existing variable with the same name:

Same goes for local, fyi.

>perl -E"say 0+\$x; local $x; say 0+\$x;" 4885852 2403948

I've often wished (and occasionally argued in favour of), that for didn't localise pre-existing, lexical loop variables.

It would be useful and intuitive. It would drastically change the behaviour of the following, though

for $lex (...) { push @f, sub { ... $lex ... }; }

As it is now, I never use a pre-existing var.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009865]
help
Chatterbox?
marioroy LWP::Simple works best with Perl v5.26 on Windows. Any Perl version is fine on Cygwin and Unix.
[karlgoethebier]: Hi mario
[marioroy]: Hi karlgoethebier.
[karlgoethebier]: "Long time No See" ;-)
[marioroy]: Yes. I've been working on MCE and MCE::Shared. These are completed and released. MCE 1.830 and MCE::Shared 1.831. Saw the LWP::Simple and P::FM thread and thought to help out.

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2017-09-23 15:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (272 votes). Check out past polls.

    Notices?