Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^4: Regular expressions across multiple linesby Marshall (Canon) |
on Apr 25, 2016 at 00:17 UTC ( [id://1161409]=note: print w/replies, xml ) | Need Help?? |
This looks mainly right, but with some quibbles.
1) Correct, the standard text line endings are: That a standard network socket (of course even on Unix) uses "Windows" line endings may be news to some.
2) The chomp
description is not 100% clear.
When reading in text mode and with the default input record separator of "\n",
chomp() will remove any of the line endings that "\n" could mean 3) Some ancient Unix functions like lp (line print) will not work with Windows line endings. Perl is fine, but lp not. In that case: while(<>){chomp;print;} will set things right. I have used this many times on Unix to convert a mixed file to <LF> endings and vice versa on Windows to convert to <CR><LF>. Although my Windows programs just don't seem to care. 4) I don't know how these test cases were generated. There is no way to do that without being in Perl bin mode or writing a C program. Update: well it appears that Perl doesn't like old Mac endings on my Windows XP machine. This does work with the <LF> ending. So something like "works between Unix and Windows" may be closer to the truth (dual platform) rather than "multi-platform". On Unix, Perl has to be able to read from both hard disk files and network sockets which have different line endings.
In Section
Seekers of Perl Wisdom
|
|