#!/usr/local/bin/perl -w use strict; use XML::Simple; use Math::Currency; my $xml = join "", <>; my $ref = XMLin( \$xml ); my $total = 0; my @items = (); for my $entry ( @{ $ref->{ "AccountEntries" }->{ AccountEntry } } ) { # ignore payments next if $entry->{ ItemID } == 0; my $amount = $entry->{ "NetDetailAmount" }->{ content }; # ignore free items next if $amount == 0; my $mc = Math::Currency->new( $amount ); print "$mc\n"; $total += $mc; } my $invoice_amount = $ref->{ AccountSummary }->{ "InvoiceNewFee" }->{ content }; print "Total: $total\n"; print "Invoice: \$$invoice_amount\n";