>I wrote my first MacPerl script today. It will batch process hundreds of >text documents into html (...I hope...). > >My question: > >What is the best way to change the Mac \r to the Unix \n? > Hi, Here's a little program that automatically sets the line terminator for Mac, DOS or Unix. Save it as a droplet, make some little text files in BBEdit with different line terminators and drop the files on the droplet to test it. I usually let Fetch get text files in TEXT/ASCII mode, so that the files not only have Mac line terminators, but also the right Creator, ready for double clicking. Rene' #!/usr/bin/perl -w foreach $f (@ARGV) { print "\n"; $/ = getLineTerminator($f); @terminators = unpack('C*',$/); print "\$/ = @terminators\n"; open (INFILE, "$f") || die "could not open infile $f"; foreach (<INFILE>) { chomp; print "$f:$_\n"; } # foreach close (INFILE); } # foreach sub getLineTerminator { my ($buf); open (INFILE, $_[0]) || die "could not open infile $f"; read INFILE,$buf,255; close (INFILE); return "\015" if ($buf=~/\015[^\012]/); # $/=CR (MAC) return "\015\012" if ($buf=~/\015\012/); # $/=CRLF (DOS) return "\012" if ($buf=~/[^\015]\012/); # $/=LF (UNIX) } # foreach ----------------------------------------- Rene' Laterveer | work: latervee@saclantc.nato.int | home: latervee@ccc.it | Phone: +39-0187-527-416 | Fax: +39-0187-527-330 | ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch