in reply to read a file and build HoA
Hello sstruthe,
I think you’re looking for something like this:
#! perl use strict; use warnings; use Data::Dump; my %dedicated; while (my $line = <DATA>) { chomp $line; my ($key, $values) = split ' ', $line; push @{ $dedicated{$key} }, $_ for split ',', $values; } dd \%dedicated; __DATA__ names1 john,bob,stu names2 mike,john,bob names3 blah
Output:
22:16 >perl 1478_SoPW.pl { names1 => ["john", "bob", "stu"], names2 => ["mike", "john", "bob"], names3 => ["blah"], } 22:17 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|