in reply to Deleting specific element in array in FOREACH loop

For something like this, I usually use a hash rather than an array, so that I can use delete() on the hash element. Maybe something like this (untested):

my %hash; for my $i (0 .. 7) { $hash{$i}++; } foreach (keys %hash) { # do stuff delete($hash{$i}) if ($condition); }

No good deed goes unpunished. -- (attributed to) Oscar Wilde