[wplug] Converting Line Terminations
jsbillings at mac.com
jsbillings at mac.com
Thu Feb 7 12:42:25 EST 2002
While the perl is technically correct, it would be just as easy to do
this:
perl -pi -e "s/\r//" filename
On Thu, 2002-02-07 at 11:19, Peter Williams wrote:
> Hey look, it's something I can reply to! : )
> *comes out of lurking*
>
> To set this up in perl, you'd use the following:
>
> #!/usr/local/bin/perl
>
> $filename = $ARGV[0];
> open (FILE, $filename);
> @file = <FILE>;
> close(FILE);
> foreach $line (@file) { $line =~ s/\r//; }
> $file2 = join ("", @file);
> open (FILE2, ">$filename.fixed");
> print FILE2 $file2;
> close(FILE2);
> 1;
>
>
> Dos/Win newline is \n\r
> *nix uses only the \n
>
> There's also a text editor I'm really attached to when using Win,
> which lets you convert between dos and *nix formats with one
> double-click (and others may offer a similar feature). It's called the
> Programmer's File Editor, created by Alan Phillips:
> http://www.lancs.ac.uk/people/cpaap/pfe
> Even though they aren't continuing development anymore, it's a
> solid program with lots of great features. Beats out Notepad or
> Wordpad easily.
>
> Hope this helps. (And sorry if someone beat me to this, I get the
> digest)
>
> All the best,
> Peter
>
>
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
More information about the wplug
mailing list