in reply to How to use a splice inside a foreach

> Original code bugged

Sorry I'm too busy to run your code guessing what you wanted to do and testing what went wrong.

Care telling us what bugged°? Maybe with an SSCCE ?

It looks like you want to eliminate all array elements which have a config to be excluded.

For this I'd go for a slice @$ar = @$ar[@keep]

Just calculate your @keep beforehand, like with a grep over all indices.

BTW: Your exists construction looks redundant

Your code has various more issues...

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

update

Maybe that:

°) "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."