Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have two arrays of equal size and want to simply print an element from each array to a new output file. e.g. $array1[[0]] and $array2[[0]] to a new file etc...
I thought this would work (below) but i'm only creating one new file. Where am I going wrong? Thanks!
for (my $i=0; $i<@array1; $i++) { open (OUT, ">$$.out") or die "can't open OUT\n"; print OUT ">$array1[$i]>$array2[$i]\n\n\n"; }
Edit by BazB: add code tags around arrays.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printing to new output files within a loop
by Old_Gray_Bear (Bishop) on Dec 20, 2004 at 21:01 UTC | |
|
Re: printing to new output files within a loop
by Sandy (Curate) on Dec 20, 2004 at 20:59 UTC | |
|
Re: printing to new output files within a loop
by rir (Vicar) on Dec 20, 2004 at 21:12 UTC | |
|
Re: printing to new output files within a loop
by amw1 (Friar) on Dec 20, 2004 at 20:56 UTC | |
|
Re: printing to new output files within a loop
by hostyle (Scribe) on Dec 20, 2004 at 22:11 UTC |