[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] reading PC files script part 2 (fwd)



How about this. Converts any text file to the local platform. It doesn't
change characters in the Ascii range 128-255 (accented chars), but if a
script contains any of these, you generally don't want them changed
anyway, or the script behaviour will change.

#!perl
($\,$,)=("\n","\n");
while($file=shift) {
	($outfile=$file)=~s/\.\w{0,3}$/.new/ or $outfile.=".new";
	open(IN,$file);
	binmode($file);
	sysread(IN,$_,-s $file);
	open(OUT,">$outfile");
	my(@line)=split(/\015\012|\012|\015/);
	print OUT @line;
	close(IN); close(OUT);
	# unlink($file); rename($outfile,$file);
}

	Bart.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch