On Thu, Nov 18, 2004 at 03:05:50PM -0600, William L. Jarrold wrote:
| (2) do you know how to do this without the FNORD hack (see below)?
The `FNORD hack' isn't that uncommon, though I'd pick a better string,
one that's a lot more random. FNORD43dfg246432sdg ought to do :)
| HRM, MAYBE I SHOULDA USED PERL?
Personally, I only use sed for command line stuff. If it's
complicated enough to put into a file, it's perl and never awk or sed.
Now, /bin/sh vs. perl, that's not so easy. Quite often I start out in
/bin/sh and wish I'd started with perl later :)
| #!/usr/bin/perl -w
| use strict;
Good habits :)
| while (<>) {
| s/^%.*//go ; # remove any line beginning with %
You don't need the `go' there at all.
| s/(.*)%.*/$1/g ;# get rid of anything after a comment
s/%.*// ; would be more efficient.
| BUT, I have spent very long on this. I know the g option is for
| greedy but I do not know what o is for.
perldoc perlop
g Match globally, i.e., find all occurrences.
o Compile pattern only once.
Read perldoc perlre, perlrequick and perlretut while you're at it.
/o is a performance thing. You rarely need it.
| Most importantly:
|
| FNORD is a hack. How can I do this without FNORD?
It's a hack, but it's not a really bad hack, as long as you pick a
good string. FNORD isn't good enough -- it's a real word, sort of.
But how about this --
s/([^\\])%.*$/$1/ ;
s/^%.*$/ ;
That ought to do it. Not that I know Latex, so I'm assuming that what
you've said is correct about parsing it.
--
Doug McLaren, [EMAIL PROTECTED]
Never trust anybody whose arm is bigger than your leg.
_______________________________________________
Siglinux mailing list
[EMAIL PROTECTED]
http://machito.utacm.org/mailman/listinfo/siglinux