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

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to