# command line arguments are available to the script in the # @ARGV array. Thus the first argument is in $ARGV[0], the # second in $ARGV[1].... # Open the file specified in the first command line arg for reading open(IN, "$ARGV[0]") || die "unable to open $ARGV[0]"; # Open the file specified in the second command line arg for writing open(OUT, ">$ARGV[1]") || die "unable to open $ARGV[0]"; # stop perl making automatic \r\n => \n or \r => \n line ending # conversions which are required on Win32 and Mac respectively binmode(OUT); #set output mode as binary # now iterate over our input file on line at a time while() { # if we have a line that contains only "\n" - ie a blank line if(/^\n$/) { # then we print "\r\n" instead of the existing "\n" into our output file print OUT "\r\n"; } # otherwise just print out the totally unaltered line else { print OUT; } # else just print line with a CR } # close the input and output files close(IN); close(OUT);