G'day Scotsman,

Welcome to the monastery.

If you've come here to ask a purely SQL question, you're basically in the wrong place. However, assuming you've extracted that data (e.g. via DBI or similar) into Perl data structures, then this might do what you want:

$ perl -Mstrict -Mwarnings -E ' my @source_data = ( ["Archeologist", "Ancient projects", "Cairo"], ["Architect", "Major projects", "London"], ["Architect", "Small projects", "Sydney"], ["Architect", "Small", "Hong Kong"], ["Programmer", "Big", "Hong Kong"], ); my @search_data = ("Architect", "Hong Kong", "Small"); my @found_data; my $re = "(?:" . join("|", @search_data) . ")"; for (@source_data) { my $matches = 0; /$re/ && ++$matches for @$_; push @found_data, [$matches, $_] if $matches; } say "@{$_->[1]}" for sort { $b->[0] <=> $a->[0] } @found_data; ' Architect Small Hong Kong Architect Small projects Sydney Architect Major projects London Programmer Big Hong Kong

If you have follow-up questions, that's fine, but please read the "How do I post a question effectively?" guidelines before posting them.

-- Ken


In reply to Re: Finding best matches by kcott
in thread Finding best matches by Scotsman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.