Oct 5, 2010, 7:01 PM
Post #13 of 14
Re: [odorf] matching exact text as regex from variable
[In reply to]
i dont really know what does this mean, and how can i figure it out, but the first file has been created in windows and the second one in linux, if that has anything to do with the newline or something?
A newline is an invisible character or series of characters at the end of every line in a file. When you are typing in a file and you hit return, you have just typed an invisible newline character.
Depending on what operating system the file was created on, the newline will be entered as either an invisible:
\n (unix, mac)
A further twist is that perl recognizes whatever operating system that the perl program is running on, and perl does automatic conversions from that operating system's newlines to a plain old '\n'. So for instance, if your perl program is running on windows, and the program reads a file, perl will convert any \r\n character sequences in the file to a \n before presenting them to your program. Similarly, if you write a \n to the file, perl will convert the \n to \r\n before writing the output to the file.
So in order to understand the particulars of what's happening, you need to know what operating system the perl program is running on, and you need to know what operating system the files that your program reads were created on.
(This post was edited by 7stud on Oct 5, 2010, 8:05 PM)