Abdelrazak Younes wrote: > Steve Litt wrote: >> Of course, if it were 1200 pages and different chapters were authored >> by different people (like Samba Unleashed), you probably couldn't do >> it as a single file. > FYI, with latest 1.5, I can open a 1200 pages document (the UserGuide > copied&pasted 12 times) and type in it without any speed problem on my > 1.8 GHz laptop. Saving this doc is quite fast (3 seconds) and loading > it is 10 seconds. > > If you can find a word processor that fast I pay you a beer ;-) I'll guess that beer's pretty safe.
I've got the book I'm presently writing spread out over several files. This leads to certain challenges relating to file inclusion---see the wiki for my solutions---but otherwise I've had no problems at all. There have been a few times I've wanted to do global search-and-replaces, but most of those times what I've wanted to do has been complicated enough that I've needed the power of perl's regular expressions to do it anyway. It's so simple to write filters in perl: while (<>) { ... } that it's really a non-issue. Indeed, the following: #!/usr/bin/perl use strict; use warnings; #my %sr = (@ARGV); my $text = do { local($/); <STDIN>; }; for (my $i = 0; $i < scalar @ARGV; $i += 2) { my $k = $ARGV[$i]; my $v = $ARGV[$i + 1]; #We use the null character as delimiter #and specify multiline matches and global replacement my $code = "\$text =~ s\000$k\000$v\000sg"; eval $code or die("Error in pattern for $k => $v.\n"); } print $text; is a complete such program. (We should really add options to allow the choice of multiline, case insensitive, etc. Not hard to do.) Save it as srfilter.pl, make it executable, and use it like this: srfilter.pl 'hello' 'goodbye' 'I\'m' 'I am' '([A-Z])\*=)' '\wanc{$1}' <input.lyx That will replace "hello" with "goodbye", "I'm" with "I am", and something like "Q*=" with "\wanc{Q}" globally in input.lyx and write the new file to the screen. (The last is something I actually had to do, along with several other such replacements.) Note the use of single quotes to protect shell metacharacters from expansion or interpolation. Of course, you can also use sed, or the perl-based srep (on CPAN). If you want to apply srfilter.pl it to a bunch of files at once, use the shell's own mechanisms: for fil in *.lyx; do srfilter.pl 'hello' 'goodbye' <$fil >new.$fil; done That's bash. If you use something else, adapt as necessary. Richard -- ================================================================== Richard G Heck, Jr Professor of Philosophy Brown University http://bobjweil.com/heck/ ================================================================== Get my public key from http://sks.keyserver.penguin.de Hash: 0x1DE91F1E66FFBDEC Learn how to sign your email using Thunderbird and GnuPG at: http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto