[Chicago-talk] appending hashes

Jay Strauss me at heyjay.com
Mon Nov 3 11:11:16 CST 2003


Thanks Andy,

Yeh I knew it was just (sorta) a list, that's why I tired "push", but I
didn't think about (@a, @b) or (%a, %b) to produce another list

Jay
----- Original Message -----
From: <Andy_Bach at wiwb.uscourts.gov>
To: "Chicago.pm chatter" <chicago-talk at mail.pm.org>
Sent: Monday, November 03, 2003 10:22 AM
Subject: Re: [Chicago-talk] appending hashes


> my %h = (a=>1, b=>2, c=>3);
> my %a = (d=>4, e=>5);
>
> %h = (%h, %a);
> for my $key ( keys %h ) {
>   print "Key: $key: $h{$key}\n"
> }
>
> A hash is just (sort of) a list of key value pairs, so making one big
> array/list of it ...  the '=>' Supercomma is just a comma that
> automatically quotes the lhs, i.e
> my %a = ('a', 1, ...);
> is the same as:
> my %a = (a => 1, ...)
>
> %h = (%h, %a);
> just unrolls the hashs and rolls them all back up again.
>
> You'd think there'd be a way to push (%a) on to the end of %h w/o
> unrolling %h (what if its really big or something?) but, besides the map
> sort of method, I can't think of a way.
>
> a
>
> Andy Bach, Sys. Mangler
> Internet: andy_bach at wiwb.uscourts.gov
> VOICE: (608) 261-5738  FAX 264-5030
>
>
>  "I'm not sure what LInux-friendly means"
> Martin Taylor, MicroSoft's Linux strategist
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at mail.pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
>




More information about the Chicago-talk mailing list