I have been working hard to find the solution on my own however I have not comprehended the iteration and concatenation. I would appreciate a hint or someone to point me in the right direction
my @numbers = (4,7,11,14);
my @numbers2= @numbers;
my @numbers3= map {"$numbers[$_]$numbers2[$_]"} 1..$#numbers ;
# result 447711111414
my $white ='w ';
my $rye =' r ';
my $italian = 'i ';
my $french = ' f ';
WANT THIS
$final_string = 'w 4 r i 4 f i 7 r w 7 f w 11 r i 11 f i 14 r w 14 f';
The @numbers array element count will vary.
There are four sandwich patterns repeated .
1st element is preceded with $white followed by $rye (5th,9th,etc)
2nd element is preceded with $italian followed by $french (6th,10th,etc)
3rd element is preceded with $italian followed by $rye (7th,11th,etc)
4th element is preceded with $white followed by $french (8th,12th,etc)
after iterating it would be $final_string
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.