I have array
@some = (a,b,c,d)
And I have a scalar that is in the loop so each time its value is different.
E.g
First time in loop
$TEST = 1
Second time in loop
$TEST=2
etc.
I need to write the program that will concatenate these 2.
I need to have a new array that will like this:
my @new;
$new [0] = a 1
$new [1] = a 2
$new [2] = b 1
$new [3] = b 2
$new [4] = c 1
etc…
Right now I have array that looks like this:
$new[0] = a
$new[1] = 1
$new[2] = a
$new[3] = 2
$new[4] = b
etc.
Please help.
I am using push to put this array in @result. And then I
am putting $test values in.
I am trying to have this new array where the first element will be $ne
+w[0] and first value of $test.
for ($k=0;$k<$num_a;$k++){
$num_b = @lad;
for ($y=0;$y<$num_b;$y++){
$lad[$y]=~/^(.*?)=(.*?)$/;
$test = $2;
chop($test);
push(@result,$new[$k]);
push(@result,$test);
}
}
print "RESULT = @result\n";
UPDATE:
Limbic~Region,
thanks a lot. That works.
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.