#!/usr/bin/perl
#
# Author: Tao Cheng <tao@netscape.com>
# Date  : Feb. 09, 2000
# Modified by Akkana to convert Mac files as well.
#
# purpose: dos2unix
#

require 'getopts.pl';

#
# Usage: $progname [filename | directory]*
#
sub usage {
    die
"\n",
"  Usage: $progname in_file out_file \n",
"\n";
}

sub tounix() {
	$fil = $_[0];
	$bak = $fil . ".bak";
	print "\nConverting $fil, leaving original in $bak\n";
	
	rename ($fil, $bak);
	open (inFILE, $bak);
	open (outFILE, "> $fil");
	
	while ( <inFILE> ) {
		$_ =~ s/\r\n/\n/g;
		$_ =~ s/\r/\n/g;
		print outFILE $_;
	}
}

#--------------------------------------------------------------------------
#  main body
#--------------------------------------------------------------------------
#
# Extract base part of this script's name

($progname) = $0 =~ /([^\/]+)$/;
&usage if ($#ARGV < 0);

&tounix(@ARGV);
