[Pdx-pm] Hash question
Roderick A. Anderson
raanders at acm.org
Mon Nov 24 15:09:37 CST 2003
On 21 Nov 2003, Randal L. Schwartz wrote:
> I think it's even been shown that iteration is better:
>
> my @array = $db2->DataHash();
> while (@array) {
> $SignUpInfo{shift @array} = shift @array;
> }
Very cool. Amazingly simple once you see it.
> Of course, I'm cheating here, knowing that the left side
> is eval'ed before the right. If you don't want that much magic:
This is a great point to keep in mind. Magic works for me. And when
someone else looks at the code I can impress the hell out of them with
this neat trick. :-)
> my %tmp = $db2->DataHash();
> while (my ($k, $v) = each %tmp) {
> $SignUpInfo{$k} = $v;
> }
I was hoping to avoid this as it seemed _so_ sledge-hammerish. I used it
for awhile but wasn't happy with the concept. I really like the one
above.
Thanks for the insight.
Rod
--
"Open Source Software - Usually you get more than you pay for..."
"Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL"
More information about the Pdx-pm-list
mailing list