in reply to Question of scope and syntax
There are many inappropriate uses of my in your script. The one that is causing the warning that you're seeing is in line 36, where you say, "open(my $currentDirectory, my $pathToDirecory)...". That one is inappropriate because $pathToDirectory is declared on line 35 already.
Another inappropriate use is where you say push( my ..., which occurs on lines 25 and 39. The reason that's inappropriate is that every time you try to push, you're declaring a new version of the variable, masking the previous one. Consequently, the variable you're pushing onto will never have more than one element pushed to it, for every push is pushing to a new variable.
There are so many additional problems it's hard to know where to start. Line 21 slurps a file into an array, and then lines 23-26 try to read from the already exhausted file-handle.
Line 34 declares $boxBegining within the while loop's conditional, and increments it. That's going to create some wonky and possibly undefined behavior relating to the fact that 'my' has both compiletime and runtime effects. Declare that variable outside of the loop.
Line 49 should be something more like this:
@contentsOfDirectory = grep { $seen{$_} } @contentsOfDirectory;
That would eliminate the need for the grep in line 59. The same goes for line 55 and 60.
I can't explain the >= issue. But I'll bet if you fix the while loop with a 'my' in the conditional the problem will go away. In fact, it does:
while ($boxEnd >= $boxBegining++) {
Dave
|
|---|