http://qs321.pair.com?node_id=692588

mhearse has asked for the wisdom of the Perl Monks concerning the following question:

I have a hash with several thousand elements. It basically contains items from the slow query log. To avoid duplicate or very similar queries, I'd like to trim down the hash based on the uniqueness of the query element. How can I do this? The query will probably differ only slightly. I guess I could start with an eq match. But that will not get them all. Thanks in advance.
my %sq_ds_uniq; for my $key (keys %sq_ds) { for my $key_uniq (keys %sq_ds_uniq) { ### This line is metacode last if $sq_ds{$key}{query} is like $sq_ds_uniq{$key_uniq}{que +ry}; } $sq_ds_uniq{$key} = $sq_ds{$key}; }
'11102' => { 'user' => 'sql_user', 'rows_sent' => '0', 'rows_exam' => '32348', 'query_time' => '55', 'log_time' => '13:11:13', 'query' => 'select something from somewhere', },