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

[perl #105850] $_ does not work as expected within "given" block

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
December 10, 2011 11:52
Subject:
[perl #105850] $_ does not work as expected within "given" block
Message ID:
rt-3.6.HEAD-5084-1323546712-1400.105850-15-0@perl.org
On Sat Dec 10 09:55:36 2011, fany@cpan.org wrote:
> 
> This is a bug report for perl from fany@cpan.org,
> generated with the help of perlbug 1.39 running under perl 5.14.2.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> 
> When I use a function which expects a codeblock as first
> argument, like List::Util::first(), within a "given" block,
> then $_ within that codeblock does not work properly, but
> keeps the value of the $_ from the "given" block.
> 
> Or, in other words, the test script below will output the
> following:
> 
> 	1 - 2 - 3 - grep OK!
> 	1 - first OK!
> 	1 - fpp OK!
> 	1 - 2 - 3 - grep within given OK!
> 	0 - 0 - 0 -
> 	0 - 0 - 0 -
> 
> Kind regards,
> fany

This is a known issue, #67694.  given does an implicit ‘my $_’.  See
also ticket #90018 and ticket #53186 (marked as resolved, even though it
isn’t).

RJBS: Would you be adverse to changing ‘given’ to alias $_ properly, or
is it too close to 5.16 at this stage?

-- 

Father Chrysostomos


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