in reply to Hashes of arrays populated from a Text File

Use a hash-of-arrays (perldsc)
use warnings; use strict; use Data::Dumper; my %Diag; while (<DATA>) { my ($name, $val) = split; push @{ $Diag{$name} }, $val; } print Dumper(\%Diag); __DATA__ Name1 1234 Name2 9999 Name1 5514 Name3 5415 Name2 6419

Replies are listed 'Best First'.
Re^2: Hashes of arrays populated from a Text File
by Raya4505 (Novice) on Feb 26, 2014 at 15:36 UTC

    That is what my code essentially already does. I am needing the script to combine the names that are the same and compile the date in one hash. I want the values to be able to repeat, but not the names. Sorry if that wasn't clear.

    The data should look like:

    Name1 => value1 value2 value3 Name2 => value4 value5 value5 Name3 => value6 value7 value8
      Unless I've mis-interpreted it, having done the hard work as posited by toolic, the problem is now down to the printed representation - maybe this, or something not unlike it, is more along the lines of what you're seeking...
      use warnings; use strict; use Data::Dumper; my %Diag; while (<DATA>) { my ($name, $val) = split; push @{ $Diag{$name} }, $val; } print "$_ => " . join(' ', @{$Diag{$_}}) . "\n" for keys %Diag; __DATA__ Name1 1234 Name2 9999 Name1 5514 Name3 5415 Name2 6419

      A user level that continues to overstate my experience :-))

      Have you run toolic's code? It does exactly what you desire.

        Good grief. I am so silly. I had a typo. It works perfectly. You rock, I stink! Thanks so much!!!
        Yes, I did and I guess I must be missing something. It is printing out symbols. I'll toy with it some more, but the data output he showed isn't exactly what I'm looking for. Thank you though