http://qs1969.pair.com?node_id=443929


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

You could easily fix that by adding a counter:
@array = map { $_ eq "c" && !$found++ ? ("c","f") : $_ } @array
(as a sub)
sub insert_after_first { my $arr_ref = shift; my $to_insert = shift; my $insert_after_me = shift; my $found = 0; map { $_ eq $insert_after_me && !$found++ ? ( $insert_after_me, $to +_insert ) : $_ } @$arr_ref; }
--------------
"But what of all those sweet words you spoke in private?"
"Oh that's just what we call pillow talk, baby, that's all."