[Warszawa-pm] Bug in Perl: Strange $_ inside 'for' nested in 'map'

Tadeusz Sośnierz tadeusz.sosnierz w onet.pl
Śro, 26 Lis 2014, 03:56:05 PST


On 26.11.2014 12:28, Stanislaw Romanski wrote:
> Cześć,
>
> Muszę się pochwalić: znalazłem prawdziwy błąd w Perlu !
> Oto w miarę minimalny przykład:
> =================================================
> #!perl -w
> # test447.pl
> # With the commented-out instruction in the line 11
> # - this code prints strange values for the table elements of indices 1
> and 2. Why ?
> # Un-commenting the line 11 - or inserting any other instruction inside
> 'map' or 'for'
> # - makes the code to run properly.  Bug or feature ?
>
> use strict;
> use warnings;
> map {
> #      my $this_instruction_seems_to_be_completely_irrelevant = 111;
>       for (my $i = 0;  $i <= 0;  $i++ ) {
>           print "$_\n";
>       }
>     } ('abc', 'def', 'ghi', 'jkl', 'mno');
> =================================================

Wow, ten zakomentowany kod który zmienia sytuację wygląda bardzo 
ciekawie :) Możesz podesłać link do fixa? Znalazłem Twój bug na 
http://www.nntp.perl.org/group/perl.perl5.porters/, ale nie mogę się 
nigdzie dopatrzyć rozwiązania.

Pozdrawiam,
Tadek



Więcej informacji o liście Warszawa-pm