Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'am using code similar to the following:
It produces the following output#!/perl/bin/perl.exe -w use strict; my @data = ( ["1040564312", "IN", 258381720], ["1040564312", "OUT", 4194077715 ], ["1040564322", "IN", 258385268], ["1040564322", "OUT", 4194081727], ); foreach my $record (@data) { for my $i (0 .. 2) { print $record->[$i] . " "; } print "\n"; }
What I need it to do is calculate the difference of element 0 from itmes 1 and 2 (i.e. 1040564312 - 1040564312 = 0), and then print the IN value followed by the OUT value so the output should be:1040564312 IN 258381720 1040564312 OUT 4194077715 1040564322 IN 258385268 1040564322 OUT 4194081727
0 258381720 4194077715 0 258385268 4194081727
Any suggestions?
update (broquaint): title change (was Array)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array
by fruiture (Curate) on Nov 27, 2002 at 19:10 UTC | |
by Anonymous Monk on Nov 27, 2002 at 19:20 UTC | |
by fruiture (Curate) on Nov 27, 2002 at 19:44 UTC | |
|
Joining records from a file(was Re: Array)
by demerphq (Chancellor) on Nov 27, 2002 at 20:41 UTC |