while ( -1 < ( $i = firstidx { $_ == $val } @array ) ) { ... }