Skip to content

Instantly share code, notes, and snippets.

@paveljurca
Last active January 5, 2017 17:58
Show Gist options
  • Save paveljurca/dddad03b484d883151a60666b943a3bc to your computer and use it in GitHub Desktop.
Save paveljurca/dddad03b484d883151a60666b943a3bc to your computer and use it in GitHub Desktop.
Replace CRLF with SPACE
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