sivasakthi wrote:
> On Mon, 2007-10-29 at 17:06 +0530, Kaushal Shriyan wrote:
>
>
>   
>> ########################################################
>>
>> #!/usr/bin/perl -w
>>
>> %states = ( "California","Sacramento", "Wisconsin","Madison", "New York",
>> "Albany");
>>
>> print "Capital of California is " . $states{"California"} . "\n\n";
>>
>> ########################################################
>>
>> I did not understand the statement $states{"California"} in the above print
>> statement of the code
>>
>> I know the the dot is a concatenation operator and \n is a newline character
>>     
>
>
>
> Hi  Kaushal,
>
> %states is a hash array
> California  is a key value
>
> $states{"California"}  means the value of hash($states)  key(California)
> is Sacramento
>
>
> More information : # perldoc -q hash
>
>   
I'd recommend `perldoc perldata`.  For this particular instance in a
nutshell...you can initialize a hash as a list of keys followed by their
values (which is I believe how they are stored...the answer to that is
likely in the above reference topic).  Therefore, each *even* indexed
hash item (starting with 0) becomes a key, and accessing that key by
name (such as as $states{"California"}) will return the following item.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to