Strange values ​​/ behavior $ _

The output should be aaabbbcccdddeee, notaaa555234dddeee

perl -wle'
    map { for (my $i =2; $i <5; $i++) { push @a, $_ } } "a".."e";
    print @a
'
aaa555234dddeee

expected behavior only when passing / dereferencing a variable $_,

perl -wle'
    map { for (my $i =2; $i <5; $i++) { push @a, ${\$_} } } "a".."e";
    print @a
'
aaabbbcccdddeee

Is this a documented error (or function)?

+4
source share
1 answer

It seems to me that this is an example of an error reported only last month (but it was about 12 years old): https://rt.perl.org/Public/Bug/Display.html?id=123285

It is fixed, but I still do not believe in any released version.

+5
source

Source: https://habr.com/ru/post/1569071/


All Articles