in reply to Nested Foreach Loop skipping every other element??

See http://perldoc.perl.org/perlsyn.html#Foreach-Loops:

If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body, for example with splice. So don't do that.
  • Comment on Re: Nested Foreach Loop skipping every other element??

Replies are listed 'Best First'.
Re^2: Nested Foreach Loop skipping every other element??
by ba1688 (Novice) on Feb 19, 2014 at 16:38 UTC
    So should how else can I delete that element??

      Instead of deleting the unwanted ones, you could push the wanted ones onto a new list. Or try to rewrite your conditions into a grep statement.

      Instead doing splice on the same @DIR which you used in the foreach, you can have a copy of @DIR and you can do splice on that array. For Ex. @DIR will be used in foreach, @DIR_COPY can be used in splice.


      All is well