foreach $line (@array) { @temp = split(/ /,$line); if ( $temp[0] eq "test") { splice(@array, $current_element ,1); } }