develooper Front page | perl.beginners | Postings from September 2009

Re: Hash of Hashes

Thread Previous | Thread Next
Shawn H Corey
September 29, 2009 05:41
Re: Hash of Hashes
Message ID:
Jeff Peng wrote:
> That's in Python? :-)

Wouldn't know, don't do Python.

> Perl's both hash and array use ().
> But anonymous hash and array use {} and [].

Hashes use {}, arrays use [], lists use ().

When you set an element of a hash, you use {} to surround its key:

   $hash{$key} = $value;

When you set an element of an array, you use [] to surround its index:

   $array[$index] = $datum;

When you set both to a list, surround the list with ():

   %hash = ( 1, 2, 3, );
   @array = ( 'a', 'b', 'c', );

See `perldoc perldata` for more details.

Just my 0.00000002 million dollars worth,

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About