in reply to How to duplicate every member of an array

Note that the first method of LanX and Corion also works if assigning the doubled/tripled/etc. array directly back to the source array:

Win8 Strawberry 5.8.9.5 (32) Thu 07/28/2022 5:30:16 C:\@Work\Perl\monks >perl use strict; use warnings; use Data::Dump qw(dd); my @ra = qw(a b c d); my $n = 3; @ra = map { ($_) x $n } @ra; dd \@ra; ^Z ["a", "a", "a", "b", "b", "b", "c", "c", "c", "d", "d", "d"]


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: How to duplicate every member of an array
by soblanc (Acolyte) on Jul 28, 2022 at 13:25 UTC
    Awesome, thank you! :)