sub insert_after_first { my ($element, $insert, @array) = @_; my $hit; map {($_, ($_ eq $element and !$hit++) ? $insert : ())} @arr; }