Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-19-2011, 03:57 AM   #1
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
Perl Hash of Hash reference query


I have a Hoh Which looks like this

my %Hash = ( 'Asia'   =>   {
                            'India'    => 'Delhi',
                            'Bhutan'   => 'Thimpu',
                            'Lanka'    => 'Colombo',

             'Europe'  =>  {

                            'UK'      => 'London',
                            'France'  => 'Paris',
                            'Spain'   => 'Madrid',

            'N.America'=>  {

                            'USA'     => 'Washington',
                            'Mexico'  => 'Mexico City',
                            'Canada'  => 'Ottawa',

            'S.America'=>  {
                            'Peru'    => 'Lima',
                            'Brazil'  => 'Brasilla',
                            'Uruguay' => 'Montevideo',

            'Australia'=> {
                            'Australia' => 'Canberra',
                            'New Zealand'=> 'Wellington',
        ) ;

If i do,

my $rec1=$Hash{'Asia'};
my $rec2=$Hash{'Europe'};
my $rec3=$Hash{'Australia'};

Is $rec1,$rec2,$rec3 a reference to those sub hashes? To print a sub hashes i am doing:

map {print $_."\n" } keys %{$rec1};
Is there any way i acn use a hash slice to print more than 1 key at a time ? Thanks

Last edited by kdelover; 02-19-2011 at 04:28 AM.
Old 02-19-2011, 05:47 AM   #2
LQ Newbie
Registered: Dec 2010
Location: Germany
Distribution: SuSe, Ubuntu
Posts: 12

Rep: Reputation: 0
Of cource $rec1,$rec2,$rec3 are references to the sub hashes.

Have a look at this.

Or tell me what exactly you want to do.

Greetings B.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Hash query kdelover Programming 5 11-21-2010 10:14 AM
Password Hash Query aml1973 Linux - Security 1 12-03-2007 08:50 AM
Using hash value as key for other hash in Perl scuzzman Programming 6 02-14-2006 06:08 PM
Generating hash in perl ? MikeFoo1 Programming 3 05-21-2005 07:03 PM
frozen-buble: no hash reference rosschilen Linux - Software 3 09-05-2004 10:27 AM

All times are GMT -5. The time now is 09:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration