in reply to Perl array declaring
Generally you will want to declare your variables when you first use them. In most cases my is enough, but for a global variable you will want to use our. See perlintro#Perl variable types and Variable scoping for more information.
Also, when your code increases in size, it is useful to know where your data is coming from, and to see if you've already used it or not. Say you have an array, @stuff, that you fill early on, and need much later. But somewhere in between, you overwrite that array with different contents, forgetting its earlier use.
It can be illustrated like so:
#note: "use strict" is NOT done here #at first: @stuff = ( 1, 2, 4, 8, 16 ); #several hundered lines of code @stuff = ( "foo", "bar", "baz" ); do_something_with_words(@stuff); #and much later: do_something_with_numbers(@stuff);
The method do_something_with_numbers will probably fail. So use strict and warnings, as they will save you much headache when it doesn't work.
~Thomas~
"Excuse me for butting in, but I'm interrupt-driven..."
|
|---|