[Techtalk] On Perl

Akkana akkana at shallowsky.com
Sun Jul 28 13:18:34 EST 2002


Kai MacTane writes:
> See, one of the things I like most about Perl is the fact that There's More 
> Than One Way To Do It (TMTOWTDI) -- 
[ ... ]
> I have come to accept that lots of people have trouble with the TMTOWTDI 
> aspects of Perl, but I don't really "get" that. Can someone explain it to 
> me? How is having multiple options difficult, or annoying, or 
> uncomfortable, or whatever? Heck, I obviously can't even see what it is 
> about the multiple options that's unwanted!

I write in perl now and then but don't consider myself fluent in it.
Here's a real-world example of why TMTOWTDI makes perl difficult.

Say I'm working on a perl project, and I bump up against something I
don't know how to do.  To take a real example, say that for a given
date, I need to extract day of week, month, day of month, year, and week
of year.  I go to the Perl Cookbook, poke around in the index, and find
an example that uses some modules from CPAN that I don't have and which
aren't available as an RPM.  But the script I'm writing will be
distributed to lots of Redhat machines, so making them all go to CPAN
and install several new modules isn't an option.  

I go to my local Perl guru, who says "Oh, I always have [some other CPAN
module I don't have] installed, and it has a way to do it, so I would
just use that." No help there either.  I ask on IRC, and get pointers to
a couple other places and several other modules I don't have, and after
a lot of grepping I finally discover that Time::localtime (note, this is
different from Time or Time::local, each of which use some of the same
function names to define functions returning completely different
structures -- go figure) is installed by default on Redhat systems
and offers a way to do what I need.

This sounds great, so I write my script in terms of Time::localtime,
and it works nicely -- until I go to integrate my new function into the
Tinderbox perl scripts and discover that it doesn't work there, because
those scripts use the Posix module, and that module has variables which
override some variables in the Time::Localtime module so that localtime
now does something else, so if I want to integrate into Tinderbox I
have to rewrite my function in terms of functions from the Posix module.

(I gave up at that point, having spent more time on the project than
it really justified, and wishing I could just distribute a C binary
as part of the package -- this would be so easy in C!)

	...Akkana



More information about the Techtalk mailing list