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',
},
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.