Help for this page
use Data::Dumper; # All of your existing code goes here. print Dumper \@sorted_recs;
foreach my $record_ref ( @sorted_recs ) { foreach my $rec_line ( @{$record_ref} ) { ... print SUM2 "\n"; # put that extra newline back, to # delimit the records. }