push @{ $results[$j][$z] }, \@result_1.";"\@result_2;
The line above from your code has a syntax error, so it's hard to tell exactly what you're trying to do. Based on the results you're getting, I'd guess your actual code had another . after the second double quote. So it's taking references to the two arrays and concatenating them together as strings with a semi-colon between them, and then pushing them onto the array pointed to by
$results[$j][$z]. But treating an array reference like a string returns a value like ARRAY(0x244dd58) corresponding to the memory location of the array, not the contents of the array, which are probably what you want.
So you could do this a couple different ways. You could put the two arrays together, and save a single reference to the resulting array. Or you could save a reference to an array containing two references to your two arrays, which is probably what you want, assuming you want to be able to tell later where test1.ksh stopped and test2.ksh started.
The other issue is that push doesn't really make sense here. Your looping with $j and $z guarantees that you're only going to push onto each sub-sub-array once. So that third level of arrays isn't necessary. Just save a reference to your results in $results[$j][$z]. Using the two methods mentioned above:
#save a reference to a single array containing the lines from both sub
+-processes:
$results[$j][$z] = [ @result_1, @result_2 ];
print $results[$j][$z][0]; # print the first line of the total output
#
# or
#
# save a reference to an array containing references to two arrays eac
+h containing the output of one sub-process:
$results[$j][$z] = [ \@result_1, \@result_2 ];
print $results[$j][$z][0][0]; #print the first line from test1.ksh
print $results[$j][$z][1][0]; #print the first line from test2.ksh
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.