Also for your interest your assertion that $/ is CRLF on Win32 is wrong, nor does chomp remove the \r. As I understand it there is some internal magic the means that non binmode file read/writes get converted but you can see that $/ is "\n" - at least on my system. I have been bitten by \r not getting eaten by chomp on multiple occasions, usually related to Win32->*nix issues.
C:\>type test.pl printf "CR \\r \\%03o 0x%02x\n", ord("\r"), ord("\r"); printf "LF \\n \\%03o 0x%02x\n", ord("\n"), ord("\n"); print $^O, $/; print "\$/ length ", length $/, " is ", (unpack "H*", $/), "\n\n"; my $str = "str\015\012"; for( 1..2 ) { print "string '$str'\n"; print "length ", length $str, "\n"; chomp $str; print "string '$str'\n"; print "length ", length $str, "\n\n"; } C:\>test.pl CR \r \015 0x0d LF \n \012 0x0a MSWin32 $/ length 1 is 0a string 'str ' length 5 'tring 'str length 4 'tring 'str length 4 'tring 'str length 4 C:\>
cheers
tachyon
In reply to Re^4: Strange character beginning text files
by tachyon
in thread Strange character beginning text files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |