A very easy question on variables scope. I have a variable defined in the main code that I use inside a while loop.
my $my_variable;
while(<FILE>) {
...using $my_variable
}
if ($my_variable) -> FAILS
When I exit the loop and use the variable I get an error:
Use of uninitialized value $my_variable
Even if I enclose the variable in a naked block I follow with the error.
{
my $my_variable;
while(<FILE>) {
...using $my_variable
}
if ($my_variable) -> FAILS
}
Any suggestion?
use strict; use warnings;? If not do it and see if it gives you some warning.warningsturned on, at least.