You are right. Below is the dos2unix equivalent works on Windows
#!/usr/bin/perl -w
use strict;
use File::Temp qw(tempfile);
use File::Copy;
dos_to_unix($ARGV[1]);
sub dos_to_unix {
my($file) = @_;
my($dst, $src);
my (undef, $tmpfile) = tempfile();
copy($file, $tmpfile)
or die "Can't copy $file to $tmpfile due to: $!\n";
open($dst, ">$file")
or die "Can't open $file for write due to: $!\n";
open($src, "<$tmpfile")
or die "Can't open $tmpfile for read due to: $!\n";
binmode($dst);
while(<$src>) {
chomp;
print $dst "$_\n";
}
close($dst);
close($src);
}
|