By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,730 Members | 1,399 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,730 IT Pros & Developers. It's quick & easy.

Is Perl *that* good? (was: How's ruby compare to it older brother python)

P: n/a
In article <iL***************>,
Leif B. Kristensen <ju******> wrote:
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Cameron Laird rose and spake:
In article <iL***************>,
Leif B. Kristensen <ju******> 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.
Berthe, Birthe, Bergitte, Bergit, Birgit, BÝrte, Berit, and Brit, which
actually are interchangeable spellings of the same name, are reduced to

Here's a small sample:

$str =~ s/HN/N/g; # John --> JON
$str =~ s/TH/T/g; # Thor --> TOR
$str =~ s/CHI/KJ/g; # Torchild --> TORKJL
$str =~ s/CHE/KJ/g; # Michel --> MKJL
$str =~ s/KKE/KJ/g; # Mikkel --> MKJL
$str =~ s/KIEL/KJL/g; # Kield -> Kjeld ( --> KJL)
$str =~ s/CH/K/g; # Christen -> Kristen ( --> KRSTN)
$str =~ s/CA/KA/g; # Carl -> Karl ( --> KAL)
$str =~ s/RL/L/g; # Thorleif <=> Tollef <=> Tolf ( --> TOLF)

I use a Perl script to transform my genealogy data from a FoxPro
database to MySQL command scripts. Thanks to the excellent module
DBD::XBase by Jan Pazdziora, this is a quite simple task.

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 $name") from PHP.

Leif Biberg Kristensen
Validare necesse est
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.