Lan Barnes wrote:
IIRC there is a utility that converts Linux and DOS test. unix2dos or
somesuch. Really just EOLn.

apropos and google haven't helped. So I'll just ask.

??

Tell Mark Wolfe I'm asking before writing my own ;-)

My favorite ....

#!/usr/bin/perl
# le - line ending conversion utility
# Written by T.R. Fullhart, [EMAIL PROTECTED]

# Default line ending = unix newline
my $lineending = "\n";

# Get type
my $type = shift @ARGV;

if( $type =~ /unix/ ) {
       $lineending = "\012";
} elsif( $type =~ /dos/ ) {
       $lineending = "\015\012";
} elsif( $type =~ /mac/ ) {
       $lineending = "\015";
} else {
       print "Usage: $0 --unix|--dos|--mac\n�";
       exit 1;
}

# Collate rest of args into file array
my @files = @ARGV;

# Read each file in turn, convert, and overwrite
for my $file ( @files ) {
       open FILE, $file or next;        # thanks turnstep
       my @lines = <FILE>;
       close FILE;

       foreach my $i ( 0..$#lines ) {
               @lines[$i] =~ s/(\012|\015\012?)/$lineending/g;
       }

       open FILE,">$file";
       print FILE @lines;
       close FILE;
}
# End of le

David Looney

--
If one would give me six lines written by the hand of the most honest man, I would find something in them to have him hanged. - Cardinal Richelieu


--
KPLUG-List@kernel-panic.org
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to