Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Trimming hash based on element uniqueness

by Anonymous Monk
on Jun 17, 2008 at 22:10 UTC ( [id://692598]=note: print w/replies, xml ) Need Help??


in reply to Trimming hash based on element uniqueness

Your code would not work correctly since the last would only break out of the inner for loop and the line
$sq_ds_uniq{$key} = $sq_ds{$key};
would always be executed. I would propose the following untested solution, where the function query_like would take the role of your "is like":
my %sq_ds_uniq; my @uniq_queries = (); for my $key (keys %sq_ds) { my $query = $sq_ds{$key}{query}; if (!grep {query_like($_, $query)} @uniq_queries) { $sq_ds_uniq{$key} = $sq_ds{$key}; push @uniq_queries, $query; } }

Replies are listed 'Best First'.
Re^2: Trimming hash based on element uniqueness
by Anonymous Monk on Jun 17, 2008 at 22:17 UTC
    I just wanted to take responsibility for the last node, sorry, I was not logged in at the time... So if you want to cast a vote or comment, please do it here.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://692598]
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-25 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found