Skip to content

Instantly share code, notes, and snippets.

@nickleeh
Created August 9, 2015 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickleeh/bc99ce5140852ce7f911 to your computer and use it in GitHub Desktop.
Save nickleeh/bc99ce5140852ce7f911 to your computer and use it in GitHub Desktop.
perl -pe 's/\r(?!\n)//g'
perl -pe 's/\cM(?!\cJ)//g'
# The ?! construct is a negative look-ahead expression. The pattern matches a CR, but only when it is not followed by a LF.
#-------------------------
use strict;
use warnings;
my $a = "field1|field2|field3|fie^Mld4|fiel^Md5|field6^M";
$a =~ s/\^M(?!$)//g;
print $a;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment