in reply to Trimming hash based on element uniqueness
would always be executed. I would propose the following untested solution, where the function query_like would take the role of your "is like":$sq_ds_uniq{$key} = $sq_ds{$key};
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 |