| 1 |
use Finance::QIF; |
| 2 |
|
| 3 |
if ( $#ARGV != 0 ) { |
| 4 |
print STDERR "USAGE: qifdumper <inputfile>\n"; |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
my $qif = Finance::QIF->new( |
| 9 |
file => $ARGV[0], |
| 10 |
autodetect => 1 |
| 11 |
); |
| 12 |
|
| 13 |
while ( my $record = $qif->next() ) { |
| 14 |
print "Header: " . $record->{header} . "\n"; |
| 15 |
foreach my $key ( keys %{$record} ) { |
| 16 |
next |
| 17 |
if ( $key eq "header" |
| 18 |
|| $key eq "splits" |
| 19 |
|| $key eq "budget" |
| 20 |
|| $key eq "prices" ); |
| 21 |
print " " . $key . ": " . $record->{$key} . "\n"; |
| 22 |
} |
| 23 |
if ( exists( $record->{splits} ) ) { |
| 24 |
foreach my $split ( @{ $record->{splits} } ) { |
| 25 |
foreach my $key ( keys %{$split} ) { |
| 26 |
print " Split: " . $key . ": " . $split->{$key} . "\n"; |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
if ( exists( $record->{budget} ) ) { |
| 31 |
print " budget: "; |
| 32 |
foreach my $amount ( @{ $record->{budget} } ) { |
| 33 |
print " " . $amount; |
| 34 |
} |
| 35 |
print "\n"; |
| 36 |
} |
| 37 |
if ( exists( $record->{prices} ) ) { |
| 38 |
print " Date Close Max Min Volume\n"; |
| 39 |
$format = " %8s %7.2f %7.2f %7.2f %-8d\n"; |
| 40 |
foreach my $price ( @{ $record->{prices} } ) { |
| 41 |
printf( $format, |
| 42 |
$price->{"date"}, $price->{"close"}, $price->{"max"}, |
| 43 |
$price->{"min"}, $price->{"volume"} ); |
| 44 |
} |
| 45 |
} |
| 46 |
} |