for VAR (LIST) {
...
}
if LIST consists entirely of assignable values( meaning variables, generally, not enumerated constants), you can modify each of those vairables by modifying VAR inside the loop. That’s because the foreach loop index variable is an implicit alias for each item in the list you’re looping over. — programming perl, 118-119
use v5.20;
use Test::More tests => 1;
my @items = ( 1, 2, 2, 4 );
for my $item (@items) {
$item = $item * 2;
}
is_deeply( \@items, [ 2, 4, 4, 8 ] , 'element doubled');