|
-
Oct 2nd, 2001, 09:52 AM
#1
Thread Starter
Hyperactive Member
hashes - perl
can anyone tell me how to create a hash of hashes , and then get the values out again!
eg hash1 = (key1 = hash1a (key1a => value,
key2a => value));
not sure how to format it!!
-
Oct 2nd, 2001, 10:36 AM
#2
Frenzied Member
If I'm not mistaken...
Code:
my %hash;
$hash{$myKey} = {};
$hash{$myKey}->{$someOtherKey} = $someOtherValue;
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Oct 2nd, 2001, 10:37 AM
#3
Frenzied Member
You can check at PerlMonks.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Oct 2nd, 2001, 10:39 AM
#4
Thread Starter
Hyperactive Member
thanks
as it happens i've just found the perl monks article on this!!
-
Oct 2nd, 2001, 11:14 AM
#5
Thread Starter
Hyperactive Member
any idea how you get the values out using a foreach loop?
-
Oct 2nd, 2001, 11:32 AM
#6
Frenzied Member
Just a guess.
Code:
foreach $key (keys(\$hash($myKey))) {
#do work
}
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|