On Fri, 15 Jun 2001, Gross, Stephan wrote:
> One of the things I've been struck by on this list is how often the "my"
> declaration is used.
> For example, I never would have thought of
> foreach my $i (@data)
> What are the advantages to doing this? A while back someone showed that it
> could speed up execution. Why would this be?
The difference is how Perl allocates space for the variable. Using "my"
puts the variable into a lexical scope and keeps it out of the global name
space. These are similar in principle to a C "auto" variable. "our" does
the opposite -- it forces a variable into a global name space, kinda like
C's "extern". It's good practice to use "my" and "our" -- if you use the
strict pragma, you have to, or you will get compile time errors.
-- Brett
http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
Why does New Jersey have more toxic waste dumps and California have
more lawyers?
New Jersey had first choice.