develooper Front page | perl.perl5.porters | Postings from April 2003

pos localized with $_

Thread Next
From:
Luke Palmer
Date:
April 5, 2003 20:07
Subject:
pos localized with $_
Message ID:
ygcadf4l15e.fsf@babylonia.flatirons.org
Why doesn't pos localize along with $_ ?!

I find my self writing code like:

    sub foo {
        local $_ = shift;
        /.../g;

        my $pos = pos;
        bar($_);
        pos = $pos;

        /.../g;
    }

    sub bar {
        local $_ = shift;
        # ...
    }

If the two $pos lines weren't there, pos would be reset upon the call
to bar.  That's annoying and dwidmy.

Is this going to change for 5.10?  Should it?

Luke

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About