Search code examples
perlseparator

What is this field separator (^M)?


I run into this one while trying to parse a text file with Perl. The original file looks like this in vim: enter image description here

When I tried to print the 2nd column (87 here), somehow, the ^M showed up in vim: enter image description here

I'm just curious what this "^M" is? Does anyone know? Thanks!


Solution

  • ^M is ASCII character 13, known as a carriage return. MS-DOS uses a carriage return followed by a line feed (ASCII 10) to mark the end of a line. Unix systems use a line feed only. Usually you will "see" a carriage return when using an editor that thinks your file is using Unix style line endings but actually has MS-DOS style line endings.