If your Perl is older than 5.6, you can't use no warnings; and use warnings;, but you may consider to upgrade. If you're not able to do so, replace the no warnings line with local $^W = 0;.no warnings 'uninitialized'; if ($_[$i] =~ /^(.+?)\.(zip|t?gz|tar|bz2?|tbz)$/i) { ... }
However, if you do care that all elements should have defined values, than you need to test for defined-ness and skip if it fails the test.
So, if $_[$i] was undefined where $i is at somepoint of iteration, the execution would not even reach the first if.for (my $i = 0; $i <= $#_; $i++) { next unless defined $_[$i] and $_[$i] =~ /^(.+?)\.(zip|t?gz|tar|bz2?|tbz)$/i or $_[$i] =~ .... and so on
And yes, I'd really like to know what happens after that undef $_[$x]. This is not the usual way in constructing multi-level loop. But beyond what you've shown and asked, I sort of believe that the problem lies on your program design. The first obvious indication to me is you need to check on /^(.+?)\.(zip|t?gz|tar|bz2?|tbz)$/i twice. The second is the inner loop on the same array.
Here's another hint. Working directly on elements of @_ will often give you unexpected results, since $_[$index] is a just reference to the original argument of the corresponding element.
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
In reply to Re: Warning gets the line number wrong?
by naikonta
in thread Warning gets the line number wrong?
by Cap'n Steve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |