Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Using Tie::IxHash to keep database query keys/values in order

by bradcathey (Prior)
on Feb 15, 2017 at 23:09 UTC ( [id://1182104]=note: print w/replies, xml ) Need Help??


in reply to Re: Using Tie::IxHash to keep database query keys/values in order
in thread Using Tie::IxHash to keep database query keys/values in order

So Data::Dumper is throwing me off and Tie::IxHash just might be keeping them in order as advertised. I'll write a loop to check that. Thanks for the lesson in D::D

—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot
  • Comment on Re^2: Using Tie::IxHash to keep database query keys/values in order

Replies are listed 'Best First'.
Re^3: Using Tie::IxHash to keep database query keys/values in order
by AnomalousMonk (Archbishop) on Feb 16, 2017 at 00:52 UTC
    So Data::Dumper is throwing me off and Tie::IxHash just might be keeping them in order as advertised.

    It's unlikely that Data::Dumper has anything to do with it. As others have written, my guess would be that selectall_arrayref() is returning a reference to an entirely separate hash it generates and populates internally. After all, how would this function "know" that you want it to use the hash referred to by $data to populate with the data it is to return? I can't use Tie::IxHash to produce an example ATM, but consider:

    c:\@Work\Perl\monks>perl -wMstrict -le "package Foo::Bar { sub TIEHASH {} } ;; my $data = {}; tie %$data, 'Foo::Bar'; print $data; ;; $data = return_anon_hash_ref(); print $data; ;; use Data::Dumper; print Dumper $data; ;; sub return_anon_hash_ref { return { 'sorry' => 'charley' }; } " HASH(0x3bd06c) HASH(0x3bd15c) $VAR1 = { 'sorry' => 'charley' };
    Note that the addresses of $data in the two print statements are different, as are the contents of the referents. Nothing you do with Data::Dumper is going to change this.

    Bottom line: Write your own data display loop or routine and use whatever explicit key order you want.


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found