in reply to Re: The weirdest problem with undef
in thread The weirdest problem with undef
In this case your best bet would be to declare my (@array1, @array2) before the for loop if you want them to be available to your subroutines.OTOH this suggestion, in this form may contribute to suggest the OP to declare all of his own variables at the top of his scripts, which is indeed a bad habit many newbies have, and goes against proper scoping of variables.[SNIP]
This clearly tells me that the subroutine is looking for global variables. Declaring them as my inside a loop doesn't create global variables. So moving them to the top, like this, works fine:
I do use stuff like
myself, occasionally. But not as an alternative to parameter passing...{ my $var; sub bus { $var++; } }
|
---|
In Section
Seekers of Perl Wisdom