Is Perl *that* good?

S Koppelman temp1-nospam at nospam-hatless-nospam.com
Wed Apr 28 01:48:35 EDT 2004


Leif B. Kristensen wrote:
> Cameron Laird rose and spake:
>>In article <iL3jc.232$Yc.2330 at news4.e.nsc.no>,
>>Leif B. Kristensen <junkmail at solumslekt.org> wrote:
>>
>>>getting dynamic HTML pages up and running quickly. Perl is great for
>>>its string-handling abilities. (On my Web pages, I actually call a
>>>Perl script from PHP precisely for this reason.)
>>.
>>I hear this more often than I understand it.  Perl certainly
>>does support many string-oriented operations.  What's a speci-
>>fic example, though, of an action you feel more comfortable
>>coding in external Perl?  I suspect there's something I need
>>to learn about PHP's deficiencies, or Perl's power.
> 
> I'm glad that you asked :-)
> 
> The routine is for a phonetic search in Norwegian 18th century names,
> which can be spelled in an amazing number of different ways. As I found
> that the Soundex algorithm was useless for Norwegian spellings, I
> invented my own. It's not really an algorithm, but a series of
> substitutions that reduces names to a kind of primitives. Thus, eg.....
> 
> Here's a small sample:
> 
> $str =~ s/HN/N/g;        # John --> JON
> $str =~ s/TH/T/g;        # Thor --> TOR ....
 >
> [snip]
> 
> In theory, the web routine for phonetic searches might have been
> implemented in PHP. The trouble with that is that I would have to
> maintain both a PHP and a Perl version of the same routine. I find it
> much easier to just copy and paste the whole mess (at present about 120
> lines) between the encoding and the decoding routines in Perl, and run
> an exec("perl norphon.pl $name") from PHP.

Well, that's not PHP's fault, especially with such straightforward 
regexps. The only reason to user perl over PHP in that case is the valid 
one you cite: you already wrote the damned code in perl. ;)

Meanwhile, wouldn't it run more efficiently if you hosted your perl 
functions under mod_perl or some other persistent harness like a SOAP or 
XML-RPC daemon and had the PHP call accross to that? Execing out and 
having perl launch, compile and run your script each time is a waste of 
resources, not to mention needlessly slow. You might not notice it if 
you're the only person using it, but if there's a sudden uptick in 
traffic to your site from fellow Scandinavian diaspora genaologists, you 
will.

-sk



More information about the Python-list mailing list