#! /usr/local/bin/perl use Getopt::Long; { # Check command-line arguments for options # check if the user wants help GetOptions("h", "help"); # check if a datafile was supplied if (@ARGV[0] eq "") { print_usage(); exit; } if (($opt_h) || ($opt_help) ) { print_usage(); exit; } for my $datafile (<@ARGV>) { $newdf = $datafile."~"; rename($datafile, $newdf) || die "Could not rename '$datafile'"; open(DATAFILE, "<$newdf") || die "Could not open datafile '$newdf'"; open(FIXDFILE, ">$datafile") || die "Could not open datafile '$datafile'"; while () { # do the fix... /o = compile search string once (it's a constant!) # ... /g = global (multiple replaces ok in a single line) s/\r/\n/go; (print FIXDFILE $_) || die "Could not write to '$datafile'"; } close(DATAFILE) || die "Could not close datafile '$newdf'"; close(FIXDFILE) || die "Could not close datafile '$datafile'"; print STDOUT "Processed file: ".$datafile."\n"; } } sub print_usage { print STDOUT <