foreach $callid (sort keys %data1) { my @fields = join('', split(/[ +\t]/, @{$data1{$callid}})); print "@fields\n"; }