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


in reply to Re: Hashes of arrays populated from a Text File
in thread Hashes of arrays populated from a Text File

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

Replies are listed 'Best First'.
Re^3: Hashes of arrays populated from a Text File
by Bloodnok (Vicar) on Feb 26, 2014 at 16:49 UTC
    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 :-))
Re^3: Hashes of arrays populated from a Text File
by hdb (Monsignor) on Feb 26, 2014 at 15:46 UTC

    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
        I didn't show any output. Here is the output I get:
        $VAR1 = { 'Name3' => [ '5415' ], 'Name1' => [ '1234', '5514' ], 'Name2' => [ '9999', '6419' ] };

        Read through perldsc to print it out in whatever format you desire.

        "...It is printing out symbols..."

        What Symbols? I've lost my Crystal_ball (or i miss something). Regards, Karl

        «The Crux of the Biscuit is the Apostrophe»