in reply to Question about array reference
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
Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Question about array reference
by Pazzeo (Initiate) on Dec 04, 2011 at 15:58 UTC |