in reply to array and concatenate

Here is a slight variation on GrandFather's solution that shows you how you could construct your array of @numbers by using a list repetition operator (see "x" in Multiplicative Operators) inside the map. It also shows you how to use an iterator to cycle round the list of breads. The iterator is a reference to a subroutine that returns the next element in the @breads array each time it is called ($breadsIter->()), resetting the element to zero whenever is has passed the end of the array.

use strict; use warnings; use 5.010; my $breadsIter = do { my $idx = 0; my @breads = qw{ w r i f i r w f }; sub { $idx = 0 if $idx > $#breads; return $breads[ $idx ++ ]; }; }; my @numbers = map { ( $_ ) x 3 } 4, 7, 11, 14; my $finalStr = join q{ }, map { $breadsIter->(), $_, $breadsIter->() } @numbers; say $finalStr;

The output.

w 4 r i 4 f i 4 r w 7 f w 7 r i 7 f i 11 r w 11 f w 11 r i 14 f i 14 r + w 14 f

I hope this is of interest.

Cheers,

JohnGG