The code does more than just delete lines containing only a single uppercase letter, it also concatenates everything that remains into a single line. Is that the intent?

You actually ask how to do two contradictory things. Your first request implies deleting the line containing {T} and the following line. The last request asks that only a line containing a single letter be deleted if it follows a line containing {T}. Nowhere do you indicate if it is important that the {T} be at the end of the line.

use warnings; use strict; while (<DATA>) { no warnings "void"; m/{T}$/ .. s/^[A-Z]\n//; print; } __DATA__ 020209990421VUTVS01 00082445B3^V^V^A2^C^D^V^V^A os00 0001 000101 R S 9 +912290449 00005941^B{T} R Saturday, January 1, 2000 G1 G ^C^D^V^V^A os00 0002 000101 R S 9912290451 00004113^B{T} R G8 Gardening< January garden calendar B C

Prints:

020209990421VUTVS01 00082445B3^V^V^A2^C^D^V^V^A os00 0001 000101 R S 9 +912290449 00005941^B{T} Saturday, January 1, 2000 G1 G ^C^D^V^V^A os00 0002 000101 R S 9912290451 00004113^B{T} G8 Gardening< January garden calendar B C

Note the use of no warnings "void" to suppress the 'useless use ...' warning due to using the range operator for a side effect.

Minor alterations of the match (possibly to a substitution) can provide the other variants implied by your question.


True laziness is hard work

In reply to Re: Delete lines by GrandFather
in thread Delete lines by Anonymous Monk

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.