in reply to Strange result on array

See perlsyn:

> 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.

You don't use splice, but instead you change the arrays the loop iterates over:

@img = grep {!/$rr/} @img; @vid = grep {!/$rr/} @vid;

So don't do that.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Strange result on array
by solocazzimiei (Novice) on Apr 02, 2021 at 18:21 UTC

    So both splice and grep have almost the same crazy effect on foreach statement.. thus we will not doit ! many tanks for the confirmation