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.