I'm not sure I under stand the last part of your question. But regardless, You can simplify your processing by realizing that you have a delimited input file. Records are separated by // flags are separated by /. So with judicious use of split you have:
#!/usr/local/bin/perl use strict; # pull everything into a string my $str = join("",<DATA>); # dump the newlines $str =~ s/\n/ /g; # loop through the records (// delimited) foreach (split(m!//!,$str)) { last unless /\S/; # skip that pesky last blank + record my ($title,@flags) = split(m!/!); # break out the fields (/ de +limited) $title =~ s/\s+/ /g; # kill extra whitespace print "References:$title\n"; # print the title foreach (@flags) { # loop through the fields my ($key,$value) = split(/=/); # split into pairs $value =~ s/\s+/ /g; # kill extra whitespace print ucfirst($key)."\t$value\n"; # print each one } print "\n"; } __DATA__ TITLE An excitatory scorpion toxin with a distinctive feature: an additional alpha helix at the C terminus and its implicati +ons for interaction with insect sodium channels /interaction_site="Q8, N9, Y10, N11, C12, F17, W38, R58, +V59 and K62 form the putative bioactive surface in mature toxin (Zilberberg et al., 1997)." /channel="Sodium channel" /target_cell="Insect specific (Excitatory)" /c_end="Free" // TITLE Cloning and Sequencing of an Excitatory Insect-Selective Neu +rotoxin BmKIT cDNA from Buthus martensii Karsch /interaction_site="Sequential deletions of C-terminal resi +dues suggested Ile73 and Ile74 for toxicity. {Oren et al., 1999}" /channel="Sodium channel" /c_end="Free" //


This approach works well if the files are small. The initial read the whole file and stuff it into a string breaks down if the file is huge. If the input files are huge it can be modified to read one line at a time until it has read a full record, then stuff the record into a string and parse it. Like so:
#!/usr/local/bin/perl use strict; my $str; # holds the records #loop through the data while (<DATA>) { chomp; # kill newlines if (m!//!) { # we have a record my ($title,@flags) = split(m!/!,$str); # break out the fields(/ d +elimited) $title =~ s/\s+/ /g; # kill extra whitespace print "References:$title\n"; # print the title foreach (@flags) { # loop through the fields my ($key,$value) = split(/=/); # split into pairs $value =~ s/\s+/ /g; # kill extra whitespace print ucfirst($key)."\t$value\n"; # print each one } print "\n"; $str = ""; # zero the input buffer } else { $str .= " " . $_; # accumulate data } } __DATA__ TITLE An excitatory scorpion toxin with a distinctive feature: an additional alpha helix at the C terminus and its implicati +ons for interaction with insect sodium channels /interaction_site="Q8, N9, Y10, N11, C12, F17, W38, R58, +V59 and K62 form the putative bioactive surface in mature toxin (Zilberberg et al., 1997)." /channel="Sodium channel" /target_cell="Insect specific (Excitatory)" /c_end="Free" // TITLE Cloning and Sequencing of an Excitatory Insect-Selective Neu +rotoxin BmKIT cDNA from Buthus martensii Karsch /interaction_site="Sequential deletions of C-terminal resi +dues suggested Ile73 and Ile74 for toxicity. {Oren et al., 1999}" /channel="Sodium channel" /c_end="Free" //


This should also print the tags regardless of the number of lines. hope it helps.

-pete
Entropy is not what is used to be.

In reply to Re: about where to check the flag by dreadpiratepeter
in thread about where to check the flag by gdnew

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.