home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl,alt.sources
- From: bjaspan@athena.mit.edu (Barr3y Jaspan)
- Subject: Re: replacing " with `` and ''
- Message-ID: <1991May4.184851.3472@athena.mit.edu>
- Date: Sat, 4 May 91 18:48:51 GMT
-
- In article <DJM.91May3235942@egypt.eng.umd.edu>, djm@eng.umd.edu (David J. MacKenzie) writes:
- |> 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?
-
- Well, I won't say this is necessarily ``better,'' but it is how I would have
- done it. Note that instead of keeping track of the $leftquote state, I just
- assume some rules about how quotes are used in text (in fact, nearly the same
- rules that emacs TeX mode uses). A " that is followed by a "special symbol"
- (which i've defined to be [ \n\t.?,], probably there are others) is assumed to
- be a close-quote, and all others are open-quotes.
-
-
- #!/afs/athena/contrib/perl/perl
-
- $follow_end = "[ \n\t.!?,]";
- while (<>) {
- if (! (/^[.\']/ || /^\"/)) {
- s/\"($follow_end)/\'\'$1/g;
- s/\"/\`\`/g;
- }
- print;
- }
-
-
- --
- Barr3y Jaspan, bjaspan@mit.edu
-