#! perl # Store on screen help text in a variable $syntax = "\nCrLf.pl, Version 1.10\n"; $syntax = $syntax."Replace orphaned carriage returns (CR, 0Dx) and line feeds (LF, 0Ax) with\n"; $syntax = $syntax."CR/LF pairs (0D0Ax)\n\n"; $syntax = $syntax."Usage: CRLF.PL [ infile [ outfile ] ]\n"; $syntax = $syntax."or: any_command | PERL.EXE CRLF.PL > outfile\n"; $syntax = $syntax."or: CRLF.PL /?\n\n"; $syntax = $syntax."Where: \"any_command\" is a command that's standard output is used\n"; $syntax = $syntax." instead of \"infile\"\n"; $syntax = $syntax." \"infile\" is an ASCII file with improper line terminations\n"; $syntax = $syntax." (default: standard input)\n"; $syntax = $syntax." \"outfile\" is the corrected ASCII file\n"; $syntax = $syntax." (default: standard output)\n\n"; $syntax = $syntax."Written by Rob van der Woude\n"; $syntax = $syntax."http://www.robvanderwoude.com\n"; $out = 0; if ( @ARGV[1] ) { open( OUT, ">@ARGV[1]" ) || die "Cannot open file @ARGV[1]:\n$!\n\n$syntax"; $out = 1; } elsif ( @ARGV[0] eq "/?" ) { print $syntax; exit(1); } while ( <> ) { $line = $_; $line =~ s/\015(>!\012)/\015\012/g; $line =~ s/(