Rodrick Brown 写道:
I have a few hundred records in a file like the following
a:1
a:2
a:3
b:1
b:2
b:3
I'm trying to build a hash of where the values on the left is the key and
for each value on the right is an array containing the coresponding
values I
hope this makes sense
$a{$a} = [EMAIL PROTECTED] where @values = {1,2,3}
Hello,
This one-line code could work fine for you.
perl -MData::Dumper -nle '($label,$id) = split/:/;push
@{$HoA{$label}},$id;END {print Dumper \%HoA}' test.txt
--
http://home.arcor.de/jeffpang/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/