Home: Fun With Perl: Perl Quizzes - Learn Perl the Fun Way:
hash of hash help



chefchanyu
New User

Aug 16, 2011, 10:46 PM


Views: 43904
hash of hash help

our %test = (
%keys_1 = (),
%keys_2 = ()
);

is it possible to make this work? or any better way to do?


davidbj
Novice

Aug 17, 2011, 5:16 AM


Views: 43902
Re: [chefchanyu] hash of hash help

Here's an example:

Code
%HashOfHashes = (  
languages=>{ windows => "PowerShell",
aix => "Perl"
},
systems => { Remotepc1 => "Win32",
Remotepc2 => "Win64",
Remotepc3 => "Aix"
},
viewdir =>{ Win32 => "dir",
Aix => "ls",
Win64 => "dir"
},
);
print "Here is my list of hashes in HashOfHashes:\n--------------------\n";
foreach $keyy(keys %HashOfHashes){
print "$keyy\n";
}
print "\nIm accesing to the first hash, to see what lenguages are available for my windows\n------------------\n";
print $HashOfHashes{languages}{windows};



BillKSmith
Veteran

Aug 18, 2011, 4:14 AM


Views: 43879
Re: [chefchanyu] hash of hash help

Refer to perl's documentation. On the command line, type:

perldoc perldoc

to learn to use the tool.

perldoc perldsc

for the example that you want.

perldoc perlref

for details of complex data structures.
Good Luck,
Bill