sub printdata{ foreach (sort keys %list){ #! CHANGED $cust = $_; #! ADDED $total = $list{$cust}->{new} - $list{$cust}->{prior}; write; } } __DATA__ "fred", 10 "barney", 30 "Bam bam", 5 "Wilma", 200 "Betty", 300 # Output +-----------------------------------------------------------------+ | Monthly Recap | |----------------------------+----------+-----------+-------------+ |Account | Prior | Current | Difference | |----------------------------+----------+-----------+-------------+ |Bam bam | 5.00 | 10.00 | 5.00 | |----------------------------+----------+-----------+-------------+ |Betty | 300.00 | 10.00 | -290.00 | |----------------------------+----------+-----------+-------------+ |Wilma | 200.00 | 10.00 | -190.00 | |----------------------------+----------+-----------+-------------+ |barney | 30.00 | 10.00 | -20.00 | |----------------------------+----------+-----------+-------------+ |fred | 10.00 | 10.00 | 0.00 | |----------------------------+----------+-----------+-------------+