Hi ,
   
  Thanks for the reply. but can u help me out if the data is large and need a 
loop to store(also if possible give instructions if the record has variable or 
optional number of fields).

Jeff Pang <[EMAIL PROTECTED]> wrote:
  

Name ABC
AGE 25
Book perl
Name DEF
AGE 20
Book linux
Name GHI
AGE 21
Book PHP
.................

can anyone help me on how to store the data with hash key as the 'Name' and the 
hash strings as the details of 'AGE' and 'Book'


Hello,I think you could do it as following:

my %hash = ( 'ABC' => { 'AGE' => 25,
'Book' => 'perl',
},
'DEF' => { 'AGE' => 20,
'Book' => 'linux',
},
);

Then,you could access the final value,for example the 'perl',with this syntax:

print $hash{'ABC'}->{'Book'};

if you want to access all the value of 'ABC',you can do:

print $_," ",$hash{'ABC'}->{$_},"\n" for (keys %{$hash{'ABC'}});

Hope that helps.


--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





                                
---------------------------------
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Reply via email to