Hello fellow seekers of perl wisdom,

To me the following awk code is a piece of art. I got it from
http://www.unix.com/shell-programming-scripting/130349-fgrep-grep-awk-help-scanning-delimiters.html
I wonder if it is possible to make an equally easy to understand and fast perl oneliner:

 awk 'NR==FNR {a[$1];next} $1 in a {print RS$0}' file1 RS=">" file2 > output
cat file1 name1 name2 name3 cat file2 >name3 text text text text >name1 some kind of text cat output >name1 text text text text >name3 some kind of text

The task is to extract the names that are present in file1 from file2 plus all the text that follows it until the next ">" character. Speed is of importance as files may well be several hundred MB big. I would be eager to hear any comments on this.

cheers space_agent


In reply to awk 2 perl oneliner by space_agent

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.