in reply to Re^8: Perl Errors
in thread Perl Errors
Perl is permissive about what it receives for a text line. chomp() will remove the end-of-line character(s) - might be 1 or might be 2 bytes.
When Perl writes a line: print "something\n"; , that \n may be one or two characters depending upon the OS and the context (network communication uses 0xOA, 0x0D - no matter what the OS) - but Perl knows about this and does the "right thing".
If I transfer a file from Windows to Unix, sometimes I need to do something like this to "convert" the file:
"chomp()" is your friend as opposed to "chop()". chop() is seldom used.while (<STDIN>) { chomp; #remove line endings print "$_\n"; #write this OS's line ending }
|
|---|