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>;