Your basic problem is you're trying to do more stuff under a statement consisting only of next, the code underneath it won't ever be executed.

Second, you seem to be testing whether a line contains nothing but ");" with a bare if. Newsflash: ");" as a string has a true value. You need a better test. And "=" is not the proper comparison operator.

The following code would appear to do what you want:

while ($string=<IN>) { if ($string=~ /^FIELD/) { while($line=<IN>) { last if $line =~ /^\);$/; } } else { @lines=split(/\s+/,$string); print "@lines\n"; } }

Something else to reconsider: Apparently you treat ");" on a line of its own as special. Perhaps you should reconsider setting $/ to it, treating it as a "line" terminator? That might make things easier.

local $/ = ");\n"; local $\ = $/; while ($string=<IN>) { if ($string=~ /^FIELD/) { # no need to skip anything, everything is in $string } else { chomp $string; # get rid of trailing ");" # print will add it again, thanks to $\ @lines=split(/\s+/,$string); print "@lines\n"; } }

In reply to Re: don't want to print certain lines by bart
in thread don't want to print certain lines by dee00zee

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.