[Boulder.pm] Trickey (for a newbie) String Replacement

Rob Nagler nagler at bivio.biz
Thu May 6 09:33:08 CDT 2004


Peter Hutnick writes:
> One of my philosophical clashes with perl is that I like explicit, 
> descriptive variable names and expressions.  Perl allows (encourages) 
> stuff like that, where you have an expression who's results are all 
> implicit.

You ahve no philosophical clash with perl, whose philosophy is
TIMTOWTDI.  However, you will bash up against the Perl Intelligentsia
if you do this.

Implicit variables with dynamic scoping are simply bad programming.
It's why I also write:

    use Bla::Module ();

If you don't do this, you have no idea where any of the names are
coming from.  

> The other thing is that I will be converting specific documents with 
> this script.  Because of functional differences between HTML and LaTeX a 
> universal translator is really impossible.  I figure one that works 
> really well, but only for me, is the best solution.

You may want to look at doclifter, which converts troff to html.  One
of the dangers of this approach is that you miss something.  Write
your code with assertions so that you don't accidently miss a latex
value, e.g. if you use Luke's alg, add a rule of the form:

   q{/\\(w+)/ && die($1, ': unhandled latex command')}

And, for a shameless plug, read the "It's a SMOP" chapter in my book
which contains a DocBook/XML to HTML translator:

http://www.extremeperl.org/bk/its-a-smop

It may help you simplify Luke's algorithm so that the rules are
clearer and easier to maintain.

Rob



More information about the Boulder-pm mailing list