[Pdx-pm] Hash question

Randal L. Schwartz merlyn at stonehenge.com
Mon Nov 24 16:59:56 CST 2003


>>>>> "Roderick" == Roderick A Anderson <raanders at acm.org> writes:

Roderick> On Sat, 22 Nov 2003, Bruce J Keeler wrote:
>> You're saying that's cheaper than
>> 
>> >     @SignUpInfo{keys %tmp} = values %tmp;

Roderick> Now trying to put this in place I'm confused as hell.  Shouldn't this be

Roderick> 	$SignUpInfo{keys %tmp} = values %tmp;

Roderick> I know perl usually does the right thing with what it's handed but I 
Roderick> really don't understand the @something{} verses the $something{} here.

One is a hash element, the other is a hash slice.

Roderick> Do the curly braces over-ride(?) the at-symbol? 

Define "override".

In the same manner that we go from:

        $array[3] = "fred";

to

        @array[3, 5, 8] = ("fred", "barney", "dino");

we go from:

        $hash{"fred"} = "flintstone";

to

        @hash{("fred", "barney", "dino")} = ("flintstone", "rubble", undef);

A hash slice sets many items at once in hash, like an array slice
sets many items at once in an array.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <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!



More information about the Pdx-pm-list mailing list