Dear Masters,
How can I quickly/efficiently insert the numerical value in between alphabet from
$inst into between strings of each element in
$arref1.
Note that the numbers of alphabet in
$inst1 are
always exactly the same with numbers of string in each element of
$arref1. Here is the example of it:
my $arref1 = [
'foo bar quux bam',
'foi bir quix bim',
'foe ber quex bem',
'foa bor quax bom',];
my $inst1 = '4 A -4 C -4 B 2 D';
# intended result
my @result1 = (
'foo -4 bar -4 quux 2 bam',
'foi -4 bir -4 quix 2 bim',
'foe -4 bar -4 quex 2 bem',
'foa -4 bor -4 quax 2 bom',
);
Other example:
my $arref2 = [
'foo bam',
'foi bim',
'foe bem',
'foa bom',
];
my $inst2 = '3 A -2 D';
# intended result
my @result2 = (
'foo -2 bam',
'foi -2 bim',
'foe -2 bem',
'foa -2 bom',
);
I really don't know how to go about it. Please kindly advice.
---
neversaint and everlastingly indebted.......
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.