#!/usr/bin/perl ### slurp open (MYFILE, 'inputfile.txt'); while () { ### chomp; ## Substitute 2 or more horizontal white space with pipe # s/[^\S\r\n]{2,}/|/g; #works s/[\h+]{2,}/|/g; ## Remove Room Name s/[\w+\W+]{7,}Room No/Room No/; ## Remove pipe s/(\|Briefed Area:)/Briefed Area:/; s/(\|Drawn Area:)/Drawn Area:/; s/(\|Maximum\|)/\|Maximum Occupancy:\|/; s/(\|Hours Of Use:)/Hours Of Use:/; ## Remove obselete data s/(\|Occupancy:)//; s/(\|hrs.)//; s/(\|sq.m)//; ## Remove pipes and new lines in range # s/,+/-/ if /(^Mechanical Notes:|)/ .. /(^Lighting Notes:)/ ; # if (/(^Mechanical Notes:|)/ .. /(^Lighting Notes:)/) {s/,+/-/}; ## Push to new line s/(\|Maximum Occupancy:)/\nMaximum Occupancy:/; ### Burp; print $_ } close (MYFILE); #### #!/usr/bin/perl local $/; open my $fh, '<', 'C:/Users/bwinkley/Desktop/test/whitespace.txt' or die $!; my $txt = <$fh>; #$txt =~ s/(\n\|)/ /mg; $txt =~ s/\R\|/ /mg; for ( split '\n', $txt ) { # process each line } print $txt;