in reply to preserving hash value outside the loop
foreach my $key1 ( sort keys %seen ) { print join( "\t", $key, @{ $seen{$key1} } ); } [download]