A variable is two things: a name that's visible to a certain part
of your program, and a value (chunk memory that holds the data
associated with the name).
local() creates a new temporary value for a global variable (name).
The change is visible to other subroutines if they're called before
the block ends, because they can use the always-accessible name to
get to the value.
my() creates a new private name and a value for it. It cannot be
seen outside the block because the name is only accessible inside its
block.
Rules of thumb: "use local() for Perl's variables, my() for yours",
and "if my() doesn't work, only then use local()".
Used to have to use local() to get anonymous globs to use as
filehandles. 5.6 fixes this.