splice @$ref, do { my $i = 0; $i++ until $i > $#$ref or $ref->[$i] eq 'foo'; $i }, 1;