Hello, all
I was just bitten by some odd behavior so I decided I'd post it here and see if it's a bug, a gotcha, or a "Why are you doing that? Stop doing that!"
#!/usr/bin/env perl
use strict;
use warnings;
my $aref = [ 'a' .. 'c' ];
warn 'ORIGINAL: $aref = ', join( q(, ), @{ $aref } );
for my $letter ( eval{ @{ $aref } } ) {
$letter = 'z' . $letter;
}
warn 'NOT CHANGED: $aref = ', join( q(, ), @{ $aref } );
for my $letter ( @{ $aref } ) {
$letter = 'z' . $letter;
}
warn 'CHANGED: $aref = ', join( q(, ), @{ $aref } );
What is happening or what it seems is happening is that when I loop through the elements of an array ref that was dereferenced inside of a block eval the assignment to the loop variable doesn't stick. I'm making no judgements one way or the other I'm just wondering what everyone else thinks of this. Thank you.