in reply to parsing and get the report
I would:
Something like the following...
my %transactions; ... my @fields = split(/\s+/); my %rec; $rec{$_} = shift(@fields) for ( qw(date time tid status trname tramoun +t) ); if ( $rec{status} eq "start" ) { $transactions{$rec{tid}} = \%rec; } elsif ( $rec{status} eq "stop" ) { if ( exists($transactions{$rec{tid}}) ) { # report transaction time and amount } else { warn "ERROR: stop without start: $_"; } } else { warn "ERROR: unrecognized status: $_"; }
Update: and include the date in the transaction time calculation: think about what happens if the transaction starts late one day and stops early the following day.
|
|---|