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;
}
}