in reply to How to make a array of hashes and search them
I think you are looking for code roughly like this:
my %IDs; # when reading the ID file, for each line do something like $IDs{$current_id} = []; # and then for each line in the four other files: while (my $line = <$file>) { my ($id, $value) = split / /, $line; push @{$IDs{$id}}, $value } # and at the very end, print them all out: for my $id (sort keys %IDs) { print "$id: ", join(', ', @{$IDs{$id}}), "\n"; }
See also: perlintro, perlreftut.
If you want to keep track about which file contains which ID, you should use something like $IDs{$id}[$file_number] = $value instead of using push.
|
|---|