use strict; my @values = (1, 2, 3, 'a', 4); my $item = 'z'; foreach $item (@values) { last if $item =~ /[^\d]/; } print($item); # Prints 'z', not 'a'. #### use strict; sub test { our $item; print("[$item]"); } { my @values = (1, 2, 3, 'a', 4); my $item = 'z'; foreach $item (@values) { test(); last if $item =~ /[^\d]/; } print($item); } # Outputs "[][][][]z" # Changing "my $item" to "our $item" # changes the output to "[1][2][3][a]z" #### This is perl, v5.6.1 built for MSWin32-x86-multi-thread