in reply to for loop localisation bug?

Maybe it won't seem so much like a bug if it is demonstrated in a more familiar form:

local $_ = "I live!\n"; for (1..100) { printf "\r%d", $_; last if $_ == 50; } print "$/The value of 'this' after the loop is $_$/";

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: for loop localisation bug?
by BrowserUk (Patriarch) on Dec 29, 2003 at 19:35 UTC

    I'd counter that, as your version is coded, it is correct behaviour, but if it was coded as

    local $_ = "I live!\n"; for $_ (1..100) { printf "\r%d", $_; last if $_ == 50; } print "$/The value of 'this' after the loop is $_$/";

    It wouldn't be correct as I have explicitly overridden the implicit behaviour.

    At at this point I'm supporting what I consider would be intuatively correct behaviour. Perl ain't never gonna work this way, and I accepted that way back with cees first post:)


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!