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]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to