By no means was my coment on the unperlishness of large blocks of
variable declarations to be taken as an excuse to not declare your
variables. You should _always_ use "use strict;" in your code (and if
you do then you have no choice but to declare your variables). My
comment was only about throw away variables being declared at usage time
as opposed to at the top of the subroutine with the other (more
permanent) variables.
On 15 Jun 2001 14:53:52 -0400, Sean O'Leary wrote:
> At 01:51 PM 6/15/2001, you wrote:
>
> >It is fairly unperlish to have large blocks of variable declarations at
> >the top of a subroutine so throw away variables (like a one used only
> >within a loop) tend to get declared as they are used. The only reason I
> >can think of that would make it faster is that declaring $i this way
> >tells the compiler that $i is not going to be permanently stored, so it
> >may stay in a register.
>
> Speaking only of the foreach my $var (@... idiom, I would agree with the
> Perlishness, but there are other really good and valid reasons to use my to
> declare your variables, beside purely stylistic ones. I would discuss them
> myself, but I will let someone much more enlightened than I do the
> talking. Check out the link below for a bunch of really good info about
> variable scoping and Perl's operators for doing so. (Thanks again to
> Mark-Jason Dominus.)
>
> http://perl.plover.com/FAQs/Namespaces.html
>
> I don't think this document has been updated to cover the new keyword
> our. Check out perlfunc for that.
>
> I would write a really brief synopsis, but I think that would be very
> counterproductive in this case. I implore everyone to read *please* read
> this document. I think the lucid and elegant explanations will clear up
> much FUD and confusion about package and lexical variables. And I think it
> will help many of us to make sense of some of Perl's features. Oh, BTW,
> package and lexical variables have nothing to do with each other. Mr.
> Dominus mentions this (prominently) in his FAQ above, but it is worth
> mentioning here. Lexicals (my variables) and package variables (local, our
> variables) have *not a thing* to do with one another.
>
> Later,
>
> Sean.
>
>
--
Today is Sweetmorn, the 20th day of Confusion in the YOLD 3167
This statement is false.