Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Hashes of arrays populated from a Text File

by Raya4505 (Novice)
on Feb 26, 2014 at 15:36 UTC ( #1076266=note: print w/ replies, xml ) Need Help??


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


Comment on Re^2: Hashes of arrays populated from a Text File
Download Code
Re^3: Hashes of arrays populated from a Text File
by hdb (Prior) on Feb 26, 2014 at 15:46 UTC

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

      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»

      Good grief. I am so silly. I had a typo. It works perfectly. You rock, I stink! Thanks so much!!!
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 :-))

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1076266]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2014-11-29 03:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls