Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Quick and portable way to determine line-ending string?by John M. Dlugosz (Monsignor) |
on Aug 09, 2001 at 02:58 UTC ( [id://103272]=note: print w/replies, xml ) | Need Help?? |
Open a file and write "\n" to it.
Re-open the file and use binmode, then read it back in. The result is the desired string. Something like this... If you don't have a writable file (why not a valid temp directory??!) use a filehandle tied to a text buffer. Say, IO::Scalar. Hmm, I tried that and it didn't work, as I half-suspected. The binmode thing is done in the C Standard library functions, and Perl might be relying on that and have no real knowledge of what it means on a given platform. Are you sure you can't come up with a writable file, or a fake file that operates on the FD level rather than Perl's tie level? —John
In Section
Seekers of Perl Wisdom
|
|