I always use strict, and usually declare/initialize variables at the top of a script.
use warnings;
use strict;
my ($str1, $str2, $str3);
my @arr = ('1', '2', '3');
... do stuff with the variables ...
Does perl have any magical tricks to put the variable declaration/initialization in a subroutine or some other mechanism so that is not the top chunk of the script?
something like this (which does not work)
use warnings;
use strict;
initializeVars();
... do stuff with the variables ...
sub initializeVars{
our ($str1, $str2, $str3);
our @arr = ('1', '2', '3');
}