in reply to difference between my and local

There are many, many excellent answers above, I suggest you read all of those links! (And thanks to those that posted them, I learned a bit more about the nuances.)

I'd like to share my very simplistic way of thinking about them, which helps me keep the two separated in my head. Basically, you use my when you want to create a variable that a specific scope owns; and you use local when you want to create a "local copy" of a variable for a specific scope.

A great example of when to use local is when working with the variables in perlvar. If you have a module named NiftyModule and you declare my $/ = "\n";, you create $NiftyModule:/. That's probably not what you wanted to happen. But, declaring local $/ = "\n" makes a local copy of the special $/, which is what you want.

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law