my localizes the variable being declared to the current block, so if you are declaring a variable in a loop, and then try to access it outside of that loop you'd get a
Global symbol XXXX requires explicit package name error running the script from the command line.
use strict;
foreach (0 .. 5) {
my $foo++;
}
print $foo, "\n"; # throws error
Amel