{ local ($1, $2) = ($1, $2); # OK, so you can't actually write this. # The hacky can write local (*1, *2) = \($1, $2); instead. # Your loop: foreach my $symbol (@syms){ local $test; $symbol=~m/(\w+)\.(\d+)/; print "symbol: $symbol\t\$1: $1\t\$2:$2\n"; print "test is ",$test++,"\n"; my ($ts,$te) = ($1,$2); } }