#perl -w # preprocess-DeleteBlankLines.pl # Perl script to fix the blank lines before we fix the embedded CR/LF's that are embedded in the ULS "text" files # n6lhv@arrl.net (Wayne Smith) # created: 07-June-2005 # updated: 07-June-2005 # Set up the environment use strict; # Initialize some variables my $ulsFile = ""; my $oneRecord = ""; my $thisLine = ""; my $firstLine = ""; my $secondLine = ""; my $firstRecordFlag = "Yes"; my $firstLineFlag = "Yes"; my @allLines = ""; my $maxLines = 0; my $oneLine = ""; # Fix a single text file sub main { # Open the text file open (ulsFile, "<" . $ARGV[0] . ".dat") or die "Cannot open file '" . $ARGV[0] . ".dat' for reading..."; open (ulsFileNew, ">" . $ARGV[0] . "-new" . ".dat") or die "Cannot open file '" . $ARGV[0] . "-new" . ".dat for writing..."; # Generate a WorkBook using the command-line parameter # writeAWorkBook ($ARGV[0]); print "Reading the original file...\n"; @allLines = ; $maxLines = @allLines; print "Writing a new file...\n"; # foreach $oneLine (@allLines) { # if (substr($oneLine,0,2) eq "CP") { # print ulsFileNew "$oneLine"; # } # skip incomplete lines # } my $lineCounter = 0; $firstRecordFlag = "Yes"; foreach $oneLine (@allLines) { # $lineCounter++; $oneLine =~ s/\s+$//; # chomp($oneLine); # print ulsFileNew "length"; # print ulsFileNew length($oneLine); print ulsFileNew "$oneLine"; # if (substr($oneLine, -1, 1) eq "\r") { # print ulsFileNew "YES - $lineCounter\n"; # } print ulsFileNew "\n"; } # Close the text files close(ulsFileNew); close(ulsFile); } # Main main;