I wrote File::Edit::Portable for things like this, particularly when opening files on systems where you may not have any idea on what the endings are:
use warnings; use strict; use File::Edit::Portable; my $rw = File::Edit::Portable->new; my $file = 'scrap.txt'; # show what endings the file has currently print $rw->recsep($file, 'hex') . "\n"; my @contents = $rw->read('scrap.txt'); # rewrite the file with the desired record separator $rw->write( contents => \@contents, recsep => "\n" ); # check to see if it took print $rw->recsep($file, 'hex') . "\n";
Output:
\0d\0a # before (\r\n) \0a # after (\n)
If you've got vi/vim, simply open the file, then:
:set ff=unix
In reply to Re: Changing CRLF in Windows to LF for UNIX
by stevieb
in thread Changing CRLF in Windows to LF for UNIX
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |