I have to read a text file and build a multiple level data structure and display in the same order it was read in.

I found that Tie::IxHash module can make that happen...

Ok, the question is why do you want to use Tie::IxHash. If you want to build an ordered structure why dont you use something like nested arrays of name=>value pairs.

$var=[ 'MAIN' => [ 'ZOP' => ['Dev', undef, 'Con', undef, 'Test', undef, 'Exit', undef, 'New', undef ], 'AP' => ['Dev', undef, 'Con', undef, 'Test', undef, 'Exit', undef, 'New', undef ], 'Exit' => undef, + ] ];

Unless you have some call to address these things by their names you dont need to use a hash at all. You can iterate over such a structure pretty much as as easily as with a HoH, and preserving the order read ceases to be an issue.

---
$world=~s/war/peace/g


In reply to Re: Trouble with Tie::IxHash by demerphq
in thread Trouble with Tie::IxHash by sara2005

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.