2007/8/24, Justin The Cynical <[EMAIL PROTECTED]>:
> On Aug 23, 2:00 am, [EMAIL PROTECTED] (Lists User) wrote:
>
> *snip*
>
> > my %grouplist;
> > open HD,'groups.txt' or die $!;
> >
> > while(<HD>) {
> > chomp;
> > my @tmp = split;
> > my $groupname = shift @tmp;
> > $grouplist{$groupname} = [EMAIL PROTECTED];}
> >
> > close HD;
> > Do you know how to loop through a hash?If not,please write back to the list.
>
> Yes and no.
>
Hi,
practicalperl's solution is right.He/she created a correct datastru for you.
This is the general way to loop through that hash,
for my $key (keys %grouplist) {
print "groupname: ", $key,"\n";
print "group content: ", "@{$grouplist{$key}}" ,"\n";
}
Because $grouplist{$key} is an anonymous array,so you need to
dereference it,saying @{
$grouplist{$key}} would do that.
All you need is to read 'perldoc perldata'.
Good luck!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/