LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


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

Rep: Reputation: 36
Perl Hash of Hash reference query


Hi,

I have a Hoh Which looks like this

Code:
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:

Code:
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 03:28 AM.
 
Old 02-19-2011, 04:47 AM   #2
Bagration
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.

http://docstore.mik.ua/orelly/perl/learn/ch05_05.htm

Or tell me what exactly you want to do.

Greetings B.
 
  


Reply



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 09:14 AM
Password Hash Query aml1973 Linux - Security 1 12-03-2007 07:50 AM
Using hash value as key for other hash in Perl scuzzman Programming 6 02-14-2006 05:08 PM
Generating hash in perl ? MikeFoo1 Programming 3 05-21-2005 06:03 PM
frozen-buble: no hash reference rosschilen Linux - Software 3 09-05-2004 09:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:18 PM.

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