Last active
January 5, 2017 17:58
-
-
Save paveljurca/dddad03b484d883151a60666b943a3bc to your computer and use it in GitHub Desktop.
Replace CRLF with SPACE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use open qw/:std :utf8/; | |
@ARGV = shift; # limit to one file at once | |
# $| = 1; # auto-flush buffer | |
# open my $out, '>:utf8', 'replace_crlf_with_space.txt'; | |
my $next = <>; | |
while (my $line = $next) { | |
$next = <>; | |
if (defined($next) and $line !~ /^\s*$/) { | |
# replace CRLF with SPACE | |
# unless the following line | |
# is made of " ", "=", "-", "_" | |
$line =~ s/[\n\r]+$/ / if $next !~ /^(\s|=|-|_)\1*$/; | |
} | |
# print $out $line; | |
print $line; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment