Re: Need Hash Help



"Azazel" == Azazel <azazel@xxxxxxxxxx> writes:

Azazel> In that case you want the keys and values the other way round:

Azazel> if (!$responses{$answer})
Azazel> {
Azazel> $responses{$answer} = [ $name ];
Azazel> }
Azazel> else
Azazel> {
Azazel> push @{$responses{$answer}}, $name;
Azazel> }

Or just:

push @{$responses{$answer}}, $name;

since autovivification will Do The Right Thing when $responses{$answer} is
undef.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxxxxxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

--
Posted via a free Usenet account from http://www.teranews.com

.