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

Rob Nagler nagler at bivio.biz
Thu May 6 13:02:34 CDT 2004


Peter Hutnick writes:
> Like it or not, culture is part of the language . . .

Absolutely, but is language proscriptive or prescriptive?  The creator
of perl says that language is proscriptive, that is, defined by the
culture.  The Intelligentsia fights the proscriptive nature of Perl by
using phrases like "That's not Perlish".  A phrase like this is not
XPish, which is why I wrote my book. :-)  It's fear of change that
drives people to define Perlish.  It gives them a home base to run and
hide.

> I'm not following you here.  I've used getopts that way.  Maybe I just 
> don't know the "bad" way?

If you say:

    use Foo::Bar;

You allow Foo::Bar to pollute your name space with whatever it likes
for all time.  You relinquish control of your naming.  That's why
@EXPORT_OK is not ok imho.  I can see people wanting to bring in names
with:

    use Foo::Bar qw(foo bar);

That's a laziness thing, and in certain cases it makes sense.
However, blanket import of arbitrary symbols is a disaster waiting to
happen.   One mispelling on the importers part, and you have a whole
new set of semantics occuring.  This is why:

    eval($anything);

is probably a bad practice.  You probably want:

    eval($anything) || die($@);

If $anything contains something that isn't defined and then all of a
sudden it becomes defined, well, there you go, you've got new
semantics and you have to figure out which of your 100 rules is
causing them.

> I plan to do exactly this as the default, and have a rule like 
> s/\\.*?}//g for "pristine" mode.

Cool

> You might consider revising "subject matter oriented program evolves" in 
> the first paragraph to "subject matter oriented program (SMOP) evolves."

Done.

> Took me a while to figure out what the hell a SMOP is.

It's a play on words, actually.  SMOP in the Hacker's Dictionary is:
Simple (or Small) Matter of Programming

http://info.astrian.net/jargon/terms/s/SMOP.html

It's a derogatory term, but I believe that if you go back to the
subject matter instead of the program, you end up with a subject
matter oriented program which truly is a simple matter of
programming.   Twisted, but that's part of the Perl culture. ;-)

> The rules are going to end up in a separate file that lives with the 
> LaTeX file it works with.

Cool.  Could you not create a latex style sheet that would do the work
of converting your latex to html?

> As I said before, generality seems unachievable for this
> application.

Never.  ;-)  Check out doclifter.  It is simply amazing.  However,
your customer (even that person is yourself) probably doesn't want to
pay for any more generalization than is absolutely necessary.

> Laziness, in this case, is the better part of valor ;-)

Laziness to me is doing the simplest thing that could possibly work
(XPism) that makes me happy.  I refactor when the code doesn't feel
right, and only if it the refactoring doesn't cost "too much".  The
SMOP example in my book was refactored way too much, but then it is a
book example.  :-)

Rob



More information about the Boulder-pm mailing list