#! perl # Store on screen help text in a variable $syntax = "\nDblCr2Cr.pl, Version 1.00\n"; $syntax = $syntax."Replace double CR/LF pairs (0D0Ax) by single pairs\n\n"; $syntax = $syntax."Usage: DBLCR2CR.PL [ infile [ outfile ] ]\n"; $syntax = $syntax."or: any_command | PERL.EXE DBLCR2CR.PL > outfile\n"; $syntax = $syntax."or: DBLCR2CR.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 double 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"; # Help required? if ( @ARGV[0] eq "/?" ) { die $syntax; } # Use source file as standard input if specified if ( @ARGV[0] ) { open( STDIN, "< @ARGV[0]" ) || die "Cannot open file @ARGV[0]:\n$!\n\n$syntax"; } # Use target file as standard output if specified if ( @ARGV[1] ) { open( STDOUT, "> @ARGV[1]" ) || die "Cannot open file @ARGV[1]:\n$!\n\n$syntax"; } # Switch to slurp mode undef $/; # Search and replace standard input and write to standard output while ( ) { $line = $_; $line =~ s/\n\n/\n/g; print $line; } # Close "file" handles close( STDIN ); close( STDOUT );