Re: Need Hash Help
- From: merlyn@xxxxxxxxxxxxxx (Randal L. Schwartz)
- Date: Mon, 16 Jul 2007 15:28:09 -0700
"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
.
- References:
- Need Hash Help
- From: raymond
- Re: Need Hash Help
- From: Azazel
- Need Hash Help
- Prev by Date: Re: How to use the Perl script to substitute the string ?
- Next by Date: Re: Need Hash Help
- Previous by thread: Re: Need Hash Help
- Next by thread: Re: Need Hash Help
- Index(es):