in reply to Merging Columns from multiple files into a single file
I would do it like this:
use strict; use warnings; my %freq; foreach my $file (@files) { open my $infh, '<', $file or die $!; while (<$infh>) { chomp; my ($freq, $data) = split /\s+/, $_; push @{$freq{$freq}}, $data; } } foreach my $k (sort {$a <=> $b} keys %freq) { print "$k @{$freq{$k}}\n"; }
But this makes the assumption that there is a manageable quantity of frequencies. If the list of frequencies and values is too large to hold in memory you might just want to consider a database solution so that you could tailor your selects with appropriate detail and constraint.
Dave
|
|---|