| 1 |
use Finance::QIF; |
| 2 |
|
| 3 |
if ( $#ARGV != 1 ) { |
| 4 |
print STDERR "USAGE: readwrite <inputfile> <outputfile>\n"; |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
my $in = Finance::QIF->new( |
| 9 |
file => $ARGV[0], |
| 10 |
autodetect => 1 |
| 11 |
); |
| 12 |
|
| 13 |
my $out = Finance::QIF->new( |
| 14 |
file => ">" . $ARGV[1], |
| 15 |
record_separator => $in->record_separator |
| 16 |
); |
| 17 |
|
| 18 |
my $header = ""; |
| 19 |
while ( my $record = $in->next() ) { |
| 20 |
if ( $header ne $record->{header} ) { |
| 21 |
$out->header( $record->{header} ); |
| 22 |
$header = $record->{header}; |
| 23 |
} |
| 24 |
$out->write($record); |
| 25 |
} |
| 26 |
|
| 27 |
$in->close(); |
| 28 |
$out->close(); |