use strict; use warnings; my @array = qw( 1 2 3 4 ); for (my $index = $#array; $index >= 0; --$index){ splice (@array, $index, 1) if $array[$index] =~ /1|3/; }