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',
},
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|