in reply to difference between my and local

Perl has two different and completely unrelated systems for creating variables.

Package variables (also sometimes known as global variables) are what you get if you just start using a variable without declaring it first. You can also explicitly create package variables with "use vars" or "our".

Lexical variables are created when you use "my".

You should be using lexical variables unless you have a good reason not to.

This is explained well by Dominus in his article Coping with Scoping. He also has a follow-up article Seven Useful Uses of local where he describes seven cases where you might want to use package variables instead of lexical variables.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: difference between my and local
by jeanluca (Deacon) on Nov 15, 2005 at 13:49 UTC
    thanks for the links!!