use strict; my @l = qw/10 20 30/; my $i += $_ foreach @l; my $t; $t += $_ foreach @l; print '$t = ' . $t . "\n"; print '$i = ' . $i . "\n";