http://qs321.pair.com?node_id=443981


in reply to Re: Inserting an element into an array after a certain element
in thread Inserting an element into an array after a certain element

The Perl6 version is about the same:

sub insert_after_first( $elem, $new, *@data ) { return if @data.elems < 1; my $front = @data.shift; return ( $front, $new, *@data ) if $front ~~ $new; return ( $front, insert_after_first( $elem, $new, *@data ) ); }
I thought the parameter naming being specified in the declaration would help, but you still neet to shift the front element off of the data list for comparison or it gets real ugly.