I want to search a text file which has xml content of top 10 results returned by google. each result has the folllowing information. <url><tilte><snippet> wat i want to do is in a perl program get the same query which i given to search in google and compare that query with all 10 result "title". The one title that matches exactly should be move to top along with its associated infor. the next matching in 2nd position. Like that i want to compare the query string and sort the text file.

for eg. the file will look some thing like this.

<?xml version="1.0" encoding="utf-8"?> <resultslist> <results> <result> <url>http://www.google.com/research/pubs/archive/32686.pdf</url> <title>Effectively finding relevant web pages from linkage information + ...</title> <snippet>AbstractâThis paper presents two hyperlink analysis-based alg +orithms to find relevant pages for a given Web page (URL). The first< +/snippet> </result> </results> </resultlist>

here in this only 1 result and its associated contents i included. like that 9 more results are there. So, in this file i have to search for specific string inputted through eg.pl program and search in each title in the result. According to that i want to resort the file.. I mean the most exact match and its associated contents should be in first. the next at second.. etc


In reply to how to search a text file using perl cmd line program by sarvan

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.