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"