replacing " with `` and ''

David J. MacKenzie djm at eng.umd.edu
Sat May 4 13:59:42 AEST 1991


Here's a little script I wrote when I needed to typeset some documents
that had been written with a word processor.  Anyone have a better way
to do this in perl?

#!/usr/local/bin/perl
# Change " to `` and '' for typesetting.
# Leave unchanged lines that start with `.', `'', or `\"',
# because they are probably troff code.
# David MacKenzie, djm at eng.umd.edu

$leftquote = 1;
while (<>) {
    if (!(/^[.\']/ || /^\\\"/)) {
	while (/\"/) {
	    if ($leftquote) {
		s/\"/\`\`/;
	    } else {
		s/\"/\'\'/;
	    }
	    $leftquote = !$leftquote;
	}
    }
    print;
}
--
David J. MacKenzie <djm at eng.umd.edu> <djm at ai.mit.edu>



More information about the Alt.sources mailing list