Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

(Ovid) Re: Sorting Data::Dumper Output

by Ovid (Cardinal)
on Nov 26, 2001 at 20:07 UTC ( [id://127556]=note: print w/replies, xml ) Need Help??


in reply to Sorting Data::Dumper Output

Since hashes are inherently unordered (well, as far as the programmer is concerned), you're going to have some trouble doing that cleanly. One unclean way of doing that (for top level keys only) is:

print Dumper map [$_, $hash{ $_ }], sort keys %hash;

However, since that breaks name/value pairs into a series of array refs, you'll probably be less than pleased with the output. You could also try Tie-SortHash-1.01. I have no idea if that would work, but the documentation suggests to me that it might.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://127556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-18 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found