http://qs321.pair.com?node_id=139575


in reply to using strict and functions

In addition to the excellent technical answers you're getting, let me also add a style comment.

Only declare variables when you need them. If you need a loop variable, don't declare it away at the beginning of the routine or (horrors!) at the top of the file. Just declare it where you're gonna need it, like this:

for ( my $Index = 0; $Index < 5; $Index++ ) { ... # code here that uses $Index }
If you're going to need two variables somewhere in the middle of a block of code, declare them there. In some languages you do have to declare all variables at the beginning (Pascal, and I think BASIC) .. but C and Perl give you more flexibility. So you could write
{ # Start black of code .. .. { # Start another block of code my ( $Index, $NodeNumber ); .. .. } .. .. }
This just declares the two variables where you need them. As soon as the scope (the code between the braces) ends, the variables disappear. Very neat, very clean.

--t. alex

"Of course, you realize that this means war." -- Bugs Bunny.