#!/usr/bin/perl use strict; use warnings; use 5.010; use List::Util qw/ sum /; use lib 'lib'; use RTI::State; my $state = RTI::State->new('rt_invoice.state'); my $unpaid = $state->unpaid_invoices; foreach my $custid (sort keys %{ $unpaid }) { my @invoices = sort { $a <=> $b } keys %{ $unpaid->{$custid} }; my $owing = sum values %{ $unpaid->{$custid} }; printf "%-25s %7.2f [@invoices]\n", $custid, $owing; }