sub insert_after_first { my ($ndx, $arr, $elt, $ins) = (0, @_); $ndx > @$arr and return while $arr->[$ndx++] ne $elt; splice @$arr, $ndx, 0, $ins; }