in reply to Re: How to correct code
in thread How to correct code

You can't just add my to each first occurrence of each variable in a script and expect the script to work properly after that. What if the script has something like this?

foreach $thingy ( @lots_of_thingies ) { $all_of_them .= $thingy; } print "$all_of_them\n";

In that example, if $all_of_them is declared with my in the lexical scope bounded by the foreach loop's code block, you won't be able to print it after the loop runs out.

strict enforces not just the use of variable declaraction, but it requires that additional thought be paid to design of lexical scopes. The OP would be wise to read perlintro, perlsub, perlsyn and my for starters. Sometimes a script is just beyond converting to compliance with strictures unless one is willing to take the time for a major rewrite.


Dave