foreach my $record_ref ( @sorted_recs ) { foreach my $rec_line ( @{$record_ref} ) { print SUM2 $rec_line; } print SUM2 "\n"; # put that extra newline back, to # delimit the records. }