in reply to How to duplicate every member of an array

Another alternative is to list each element twice explicitly in the map:

@doubled = map { $_, $_ } @array

Also, you can construct the new array in a loop instead of using map:

my @doubled; for my $elt (@array) { push @doubled, $elt, $elt; }

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
    Thank you! :)