develooper Front page | perl.perl5.porters | Postings from February 2011

Re: Bug with given() localization, pos() magic, and m//gc state

Thread Previous | Thread Next
From:
Tom Christiansen
Date:
February 20, 2011 15:50
Subject:
Re: Bug with given() localization, pos() magic, and m//gc state
Message ID:
20497.1298245834@chthon
> It *is* the same variable. given() re-uses the same lexical $_
> (its own) each time.

Gee, that's ugly.  Seems broken.

> given() doesn't do any localisation or aliasing. 
> "given($foo) { ++$_ }" is a no-op.

> Just change given() to for() and never look back. :-)

Huh!!  I never thought of when() as an if() with an implicit 
next, but so it appears.   Wild!

> As far as I'm concerned, given() is broken by design.

I wonder how that happened?

--tom

Thread Previous | 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