my $idx=0; $idx++ while $array[$idx] ne 'entry' and $idx < $#array; # Added! See [272470]. [cees]++ die 'Entry not found' if $idx == $#array and $array[-1] ne 'entry'; ## $array[$idx] is (the first!!) matching entry.