Problem solved (with help from Andre Poenitz)! Attached is perl code
that replaces straight quotes with LyX code for left or right curly
quotes as appropriate. There are probably many ways to do this in one
line, but this is my first perl code, so...
This problem will be faced by anyone who imports ascii text into LyX,
text that has been saved by a word processor in another operating system
and that has been stripped of proprietary formatting codes. Manually
changing each straight quote in LyX to a left or right curly quote is a
long job for a book length document. I hope this will save others time.
Newbie that I am, I don't know how to paste the text into this e-mail,
so I have attached the file: straightQuoteConvertToLyX
#!/usr/bin/perl -w
# straightQuoteConvertToLyX
# by John Wetterau
# [EMAIL PROTECTED]
# converts ascii straight quotes to LyX curly quotes
# joe.burke.in.lyx is a novel originally written in Word for Windows.
# It was exported in MS-DOS no lines format, copied to Linux, run
# through dos2unix (to convert cr,lf to newline), and then imported
# by LyX as an ascii file. The Word export routine replaced all curly
# quotes with straight quotes. This perl code takes the lyx document, after
# it has been imported by LyX, and inserts LyX code for left and right curly
# quotes at the appropriate places. It may miss some unusual cases,
# but it worked fine for me on hundreds of pages of mixed description and
# dialog.
# hard code input and output files cuz I don't
# know any better (first perl code)
$LYXIN = "</home/jw/writing/joe.burke.in.lyx";
$LYXOUT = ">/home/jw/writing/joe.burke.out.lyx";
$LCURLY = "\n\\begin_inset Quotes eld\n\\end_inset
\n\n";
$RCURLY = "\n\\begin_inset Quotes erd\n\\end_inset
\n\n";
open LYXIN or die "Can't find file $LYXIN: $!\n";
open LYXOUT or die "Can't find file $LYXOUT: $!\n";
select LYXOUT;
while (<LYXIN>) {
# substitute for right straight quotes first
s/\."/.$RCURLY/gxm;
s/\?"/?$RCURLY/gxm;
s/,"/,$RCURLY/gxm;
s/!"/!$RCURLY/gxm;
# remaining straight quotes should be lefties
s/"/$LCURLY/gxm;
print;
}