Hi Owen,

2008/12/15 Chas. Owens <chas.ow...@gmail.com>

> On Mon, Dec 15, 2008 at 04:18, Panda-X <exilepa...@gmail.com> wrote:
> > Hello,
> >
> > I have a hash tree, which sub- and sub-sub-sub ( and whatever )
> > items inside are all hashes.
> >
> > and the next step I dealing with this hash tree is to use
> > Data::Dumper to dump it out.
> >
> > What I hope that the Data::Dumper result can keep the order as
> > what I declared at very first. Is that anyway I can do this ?
> >
> > Thank you very much for any clues.
> >
> > Regards,
> > Panda-X
> >
>
> You can try Tie::IxHash*, but it does not transparently handle
> nesting.  If your hash has a predictable structure you could write
> your own version of Dumper that knows the right order.  You could also
> store an incrementing value with each entry.
>
> It is also possible that there is a better solution, but that is
> dependent on what you are trying to do.  Can you tell us what sort of
> data you are working with that the order of a hash (a fundamentally
> unordered data structure) matters?  If it is just that you want a
> predictable order to the output, set $Data::Dumper::Sortkeys to 1.
>
> * http://search.cpan.org/dist/Tie-IxHash/lib/Tie/IxHash.pm



I am trying to deal with this structure, and this is using to ask Tk to
build the object :

my $interface = {
  MW => {
     MENU_mn => { },
     NOTEBOOK_nb => {
         TAB_tab1 => {
             BUTTON_but1 => { },
             BUTTON_but2 => { },
          },
         TAB_tab2 => {
             FRAME_frmWhatever => {
               TEXT_someContext => { },
               BUTTON_save => { },
             },
         },
     },
  },
}

But maybe I missed something inside, seems Tie::IxHash do not tie hash
tree...?
Am I correct ?

Regards,
Panda-X




> <http://search.cpan.org/dist/Tie-IxHash/lib/Tie/IxHash.pm>
>
> --
> Chas. Owens
> wonkden.net
> The most important skill a programmer can have is the ability to read.
>

Reply via email to