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
|