one row in @data looks about like this: (I produced the below line with this code:)[...] # Read in the file while (my $line = <FILE> ) { if ($csv->parse($line)) { @row = $csv->fields(); push @data, [ @row ]; } }
Anyway, what I need to do is:for ($i=0 ; $i < $lines; $i++) { for (my $j=0; $j < 6; $j++) { print "$data[$i][$j] "; } print "\n"; } QP 2/27/2008 555 1000.00 2493819320
When I was merely producing one entry per row in the array, I used the code below, which worked just fine, but summing the sales by date is throwing me.1) Generate the sum of element 3 where element 1 reoccurs in the array +. I.e., tally the day's sales. 2. Print out a line with the sum of the day's sales. 3. Print the row with each individual sale, with element 3 made negati +ve.
for ($i=0 ; $i < $lines; $i++) { $amount = $data[$i][3] * -1; print OUTFILE "some header information\n"; print OUTFILE "some more header info\n"; print OUTFILE "$data[$i][1]\t1350 Account\t$data[$i][3]\t$data +[$i][0]\t$data[$i][4]\n"; print OUTFILE "$trnsid\tt$data[$i][1]\t2600Other:$data[$i][2]\t$am +ount\t$data[$i][0] $data[$i][4]\n"; }
In reply to Silly array-ish question. by fleurdmiller
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |