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
In reply to Re: where to declare a variable...
by dvergin
in thread where to declare a variable...
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |