in reply to where to declare a variable...
A common rule of thumb is that you want to declare the variable in as narrow a scope as you can and still be able to access it where you need to.
So you could try declaring the array inside the if blocks for a very narrow scope. But then you would discover that you were not able to access it outside the scope of the if blocks -- which I presume you will want to do when you flesh out the subroutine (otherwise why load the contents of the file into the array in the first place).
------------------------------------------------------------
"Perl is a mess
and that's good because the
problem space is also a mess." - Larry Wall
|
---|
Replies are listed 'Best First'. | |
---|---|
Re(2): where to declare a variable...
by dmmiller2k (Chaplain) on Dec 09, 2001 at 23:12 UTC | |
Thanks :)
by kiat (Vicar) on Dec 10, 2001 at 20:37 UTC |