Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: table from repeated strings text

by Not_a_Number (Prior)
on Jul 14, 2015 at 17:43 UTC ( [id://1134765]=note: print w/replies, xml ) Need Help??


in reply to table from repeated strings text

Or even:

use 5.12.0; use warnings; my %HoA; while ( <DATA> ) { my @got = split; push @{ $HoA{ $got[0] } }, $got[2]; } say "$_ - @{$HoA{$_}}" for sort keys %HoA; __DATA__ aaa bbb 123 aaa ccc 234 aaa ddd 345 bbb ccc 456 bbb ddd 567 ccc ddd 678

Update: ...which could be shortened to (the no doubt less efficient, splitting the same line twice):

my %HoA; push @{ $HoA{ ( split )[0] } }, ( split )[2] while <DATA>;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-18 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found