Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: loop surprise

by RonW (Parson)
on Apr 05, 2018 at 20:43 UTC ( #1212376=note: print w/replies, xml ) Need Help??


in reply to Re^2: loop surprise
in thread loop surprise

if not de-localized, exactly what is the nature of the thing to which $_ would remain aliased after loop exit

Aliasing is an implicit reference to the object that is aliased. Like any referenced object, it would remain until all references to it have been removed.

As for why, to see what was last processed. Sure, you could use an extra variable, but doing so adds more opportunities for introducing bugs.

Besides, according to Larry, laziness is a virtue.

Replies are listed 'Best First'.
Re^4: loop surprise
by Your Mother (Bishop) on Apr 05, 2018 at 21:00 UTC

    But there is already an extra variable conceptually. $current_iterator != $last_iterated, even when they happen to be the same number/item, they are not logically the same concept. I think the possibility of introducing bugs is much larger where the iterator alias is a repurposed package variable instead of block scoped.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2019-05-22 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (140 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!