<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!c:/perl/bin/perl -w

use strict;
use Getopt::Long();
use File::Find();


my $opt = {
};

sub Convert {
  my $f = shift;
  return unless -f $f  &amp;&amp;  ! -z _;
  print "Loading file $f\n" if $opt-&gt;{'verbose'};
  open(FILE, "&lt;$f") || die "Failed to open file $f: $!";
  binmode(FILE) || die "Failed to request binary mode for $f: $!";
  my $contents;
  { local $/ = undef; $contents = &lt;FILE&gt;; }
  die "Failed to read $f: $!" unless defined $contents;
  close(FILE) || die "Failed to close $f: $!";
  my $newcontents = $contents;
  $newcontents =~ s/\r\n/\n/sg;
  if ($contents ne $newcontents) {
    print "Modifying file $f\n" if $opt-&gt;{'verbose'};
    (open(FILE, "&gt;$f") &amp;&amp; binmode(FILE)  &amp;&amp;  (print FILE $newcontents) &amp;&amp;
     close(FILE))
      || die "Failed to open file $f: $!";
  }
}

Getopt::Long::GetOptions($opt, "dir=s", "verbose");
if (@ARGV) {
  foreach my $f (@ARGV) {
    Convert($f);
  }
} else {
  my $dir = $opt-&gt;{'dir'} || ".";
  die "No such directory: $dir" unless -d $dir;
  File::Find::find(sub { Convert($File::Find::name) }, $dir);
}
</pre></body></html>