[Warszawa-pm] Bug in Perl: Strange $_ inside 'for' nested in 'map'
Stanislaw Romanski
stas w datos.pl
Śro, 26 Lis 2014, 03:28:56 PST
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');
=================================================
Opisałem to na LinkenIn, w grupie dyskusyjnel 'Perl'
"Strange $_ inside 'for' nested in 'map' - bug or feature ?"
i wysłałem perlbug report.
Father Chrysostomos poprawił błąd
i w wersji 5.22 pewnie błędu już nie będzie...
A zagnieździł się począwszy od 5.8 - czyli jakieś 12 lat temu ;-)
Pozdrawiam,
Stanisław
Więcej informacji o liście Warszawa-pm