sub insert_after_first { my ($ndx, $arr, $elt, $ins) = (0, @_); $arr->[$ndx++] eq $elt and last for 0 .. @$arr; splice @$arr, $ndx, 0, $ins if $ndx <= @$arr; }