Thread: Hash Tree

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    10
    Rep Power
    0

    Hash Tree


    Hello All

    I need to assign 2 values to the same key.
    Is it possible to do it in a hash tree?

    I defined it
    my(%hashtree)
    so if I want to insert from an array one value I do:
    %hashtree{$line[0]} = $value
    but the problem is with 2 or more keys.

    Thanks in advance,
    Have a great day!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Location
    Paris area, France
    Posts
    842
    Rep Power
    496
    You can use a hash of arrays (HoA) or a hash of hashes (HoH).

    Example:
    my %month;
    $month{"october"}[0] = "Oct";
    $month{"october"}[1] = "10";

    Or:
    $month{"october"}{"short_name"} = "Oct";
    $month{"october"}{"number"} = "Oct";

    Comments on this post

    • ishnid agrees
    Last edited by Laurent_R; March 7th, 2013 at 01:42 PM. Reason: Corrected two typos
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    10
    Rep Power
    0
    Thanks a lot!!

IMN logo majestic logo threadwatch logo seochat tools logo