Results 1 to 6 of 6

Thread: hashes - perl

  1. #1

    Thread Starter
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404

    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!!

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.

  3. #3
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.

  4. #4

    Thread Starter
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    thanks

    as it happens i've just found the perl monks article on this!!

  5. #5

    Thread Starter
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    any idea how you get the values out using a foreach loop?

  6. #6
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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
  •  



Click Here to Expand Forum to Full Width