Pazzeo has asked for the wisdom of the Perl Monks concerning the following question:
My idea was to save inside the array @results the different results of my operations performed during the last while cycle.my $j = 0; my $z = 0; my @results; while ($j <5) { while ( $z < 5) { my @result_1 = `/home/devel/test1.ksh $j`; my @result_2 = `/home/devel/test2.ksh $j`; push @{ $results[$j][$z] }, \@result_1.";"\@result_2; $z++; } $j++; }
The problem is that it seems that for every cycle perl uses the same reference, so in the end in the @results I have only 2 values repeated 5 times.
print @{ $results[0] [0] }[0] = ARRAY00001;ARRAY00002
print @{ $results[0] 1 }[0] = ARRAY00001;ARRAY00002
print @{ $results[0] 2 }[0] = ARRAY00001;ARRAY00002
and so on
How could I solve my problem? What did I do wrong?
Thanks a lot, Pazzeo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question about array reference
by roboticus (Chancellor) on Dec 03, 2011 at 16:49 UTC | |
|
Re: Question about array reference
by GrandFather (Saint) on Dec 04, 2011 at 03:03 UTC | |
|
Re: Question about array reference
by aaron_baugher (Curate) on Dec 03, 2011 at 19:00 UTC | |
by Pazzeo (Initiate) on Dec 04, 2011 at 15:58 UTC |