#!/usr/local/bin/perl


$dir = '';
$junkfile = "junkfile";
if ($ARGV[0] =~ /^-d(.*)/ ){
	$dir = $1;
	print "directory is $dir \n";
}else {
	print "Usage is dos2unix.pl -ddirectory_path\n";
	print "\tfor eg: dos2unix.pl -d/tmp\n";
	exit(0);
}
@files = `ls $dir`;
$junkfile = $dir ."/" . $junkfile;

foreach $f (@files) {
	chop($f);
	$file = $dir . "/" . $f;
	print "dos2unix $file > $junkfile\n";
	`dos2unix $file > $junkfile`;
	print "mv $junkfile $file\n";
	`mv $junkfile $file`;
}
