my $first = 1; @array = map { my @a = $_; push(@a, "x") if ($first && $_ eq "c"); $first ||= @a-1; @a } @array