Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Answer: How do I find unique Array in Array of Array?

by TedPride (Priest)
on May 12, 2006 at 02:33 UTC ( [id://548911]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: How do I find unique Array in Array of Array?
in thread How do I find unique Array in Array of Arrays?

Since this stores the Data::Dumper output for each array in %seen as a key, wouldn't it be vastly inefficient in terms of memory use? It might be better to md5 your Dumper output before using it as a key:
use strict; use warnings; use Data::Dumper; use Digest::MD5 qw/md5/; my @a = ( ['a','b','c'], ['a','b','c'], ['a','b','d'], ['a','b','d'], ); my %seen; my @b = grep { !$seen{md5 Dumper($_)}++ } @a; print Dumper(\@b);

Replies are listed 'Best First'.
Re^2: Answer: How do I find unique Array in Array of Array?
by jdporter (Paladin) on May 12, 2006 at 15:32 UTC

    Good point; but as with anything, there's a time/space tradeoff, and it's the engineer's call.

    I would say that for something like your sample data, the time it takes to calculate the MD5 would not be worth it, especially given that the memory savings would be neglible.

    In really extreme cases, you'd probably want a function that could hash a complex data structure directly, rather than a stringification of it.

    We're building the house of the future together.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://548911]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.