Hopefully, I understood your problem correctly: you want to remove the newline after every line in the text, containing only capital letters. Try this code:
#!/usr/bin/perl
use strict;
use warnings;
my $text = qq{JJJ
1234 123.00 1234.28 123456.00 1234567.72 constant
ld;afksd;l REst of file blah blah blah...rest of file and other info I neeed etc.
JJJ
1234 123.00 1234.28 123456.00 1234567.72 constant
ld;afksd;l REst of file blah blah blah...rest of file and other info I neeed etc.
};
$text =~ s/(^[A-Z]+) #if the line starts with at least 1 capital letter
\r? #followed by optional \r - for DOS files
\n$/ #followed by \n
$1 /mg; #replace it with the 1-st group and a space
print $text;
It prints:
JJJ 1234 123.00 1234.28 123456.00 1234567.72 constant
ld;afksd;l REst of file blah blah blah...rest of file and other info I neeed etc.
JJJ 1234 123.00 1234.28 123456.00 1234567.72 constant
ld;afksd;l REst of file blah blah blah...rest of file and other info I neeed etc.
I didn't read the text from file to show the test data. But you can easily add read_file
call.