Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Too Many IDs

by choroba (Cardinal)
on Jan 09, 2020 at 08:08 UTC ( [id://11111228]=note: print w/replies, xml ) Need Help??


in reply to Too Many IDs

Update: This answer isn't really helpful, sorry. Your solutions stores the same references under the sn's, so it should occupy memory comparable to my solution.

If your concern is memory, you can store just the "sn to id" map instead of storing all the data twice.

my %sn_to_id = map { $dat_by_id{$_}{sn} => $_ } keys %dat_by_id;

You then need to nest the references to get the value:

my $sn = 'b'; my $more = $dat_by_id{ $sn_to_id{$sn} }{more};

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Too Many IDs
by LanX (Saint) on Jan 09, 2020 at 11:30 UTC
    Where is the benefit to the OP's code, where the values are just the identical hash refs and no flat copies?

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11111228]
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: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found