http://qs321.pair.com?node_id=1076256

Raya4505 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, oh wise ones. I posted a previous question that I was struggling with for days and someone gave me an answer within 30 minutes, so I'm hoping to be that lucky again. I am very new to PERL so please be gentle and very simple with your answers

I am trying to populate several hashes with arrays in them all from a tab delimited text file. The format of the information is:

Name1 1234

Name2 9999

Name1 5514

Name3 5415

Name2 6419

So, as you can see, I need the script to be able to go through and put the "matches" together even though they aren't in concecutive order and then populate each matching hash key with the corresponding data; ideally the results would look like this:

Name1 => '1234','5514'; so on and so forth.

Here is the code I have. It works populating, but it doesn't combine the same names and values together, it just creates a new hash for them.

#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; my %Diag; my $file = "2009.txt"; open my $fh, "<", $file or die "Can't open $file: $!"; while (<$fh>) { chomp; undef $Diag{$_}; } print Dumper \%Diag; foreach my $k (keys %Diag) { print "$k\n"; }

I've looked on here, online and in books, can't get any of the codes to work, so any help would be amazing! Thank you so much in advance!