I've run out of time tonight, but the following may offer some ideas:

#!/usr/bin/perl # # parse the pubmed links to searchable format # use warnings; use strict; use File::Basename; my $within = 0; # within field area my $space = 0; # was last line space local $/ = '*FIELD* RF'; <DATA>; #Skip prefix stuff $/ = "\n\n"; #Read a "record" at a time while (<DATA>) { chomp; exit if m/\*FIELD\*/; tr/\n/ /d; my $record = $_; if ($record =~ m/^[^:]+:.+?\. (.+)$/) { my $extra = $1; if ($extra =~ m/(.+?) (\d+): (\d+)-\d+, (\d+)./) { print "${1}[JO] AND ${4}[DP] AND ${2}[VI] AND ${3}[PG]\n"; } } }
__DATA__ This is some prefix guff of no import. *FIELD* RF 1. Grier, R. E.; Farrington, F. H.; Kendig, R.; Mamunes, P.: Autosomal dominant inheritance of the Aarskog syndrome. Am. J. Med. Genet. 15: 39-46, 1983. 2. Teebi, A. S.; Rucquoi, J. K.; Meyn, M. S.: Aarskog syndrome: report of a family with review and discussion of nosology. Am. J. Med. Genet. + 46: 501-509, 1993. 3. Welch, J. P.: Elucidation of a 'new' pleiotropic connective tissue disorder. Birth Defects Orig. Artic Ser. X(10): 138-146, 1974. *FIELD* CS

Prints:

Am. J. Med. Genet.[JO] AND 1983[DP] AND 15[VI] AND 39[PG] Am. J. Med. Genet.[JO] AND 1993[DP] AND 46[VI] AND 501[PG]

Perl is Huffman encoded by design.

In reply to Re: Regex, loops and subs by GrandFather
in thread Regex, loops and subs by Hena

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.