in reply to about where to check the flag

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.