home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3286
< prev
next >
Wrap
Internet Message Format
|
1991-05-03
|
818b
From: djm@eng.umd.edu (David J. MacKenzie)
Newsgroups: comp.lang.perl,alt.sources
Subject: replacing " with `` and ''
Message-ID: <DJM.91May3235942@egypt.eng.umd.edu>
Date: 4 May 91 03:59:42 GMT
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@eng.umd.edu
$leftquote = 1;
while (<>) {
if (!(/^[.\']/ || /^\\\"/)) {
while (/\"/) {
if ($leftquote) {
s/\"/\`\`/;
} else {
s/\"/\'\'/;
}
$leftquote = !$leftquote;
}
}
print;
}
--
David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>