sub insert_after_first { my ($count, $arr, $elt, $ins) = (0, @_); return map {($_ eq $elt and $count++ == 0) ? ($_,$ins) : $_} @$arr; }