Re: soundex?

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Neal Becker
CC: exim-users
Subject: Re: soundex?
On Fri, 15 Nov 1996, Neal Becker wrote:

> I saw some reference to soundex in the manual. Where can I find such
> software? If anyone has interfaced it to exim, can you tell me what
> config entries you used?


The reference is to the Perl script we run for unknown users. It does a
soundes match on the name and tries to send back a helpful message. The
config pipes the messages to the script using a pipe transport. The
final director is

unknownuser:
no_verify,
driver = smartuser,
transport = unknownuser_pipe;

which matches up with the transport

unknownuser_pipe:
driver = pipe;
command = "/opt/exim/util/baduser.sh",
ignore_status,
return_output,
user = nobody

The script is highly parochial and wouldn't be of much use to anyone
else. The original soundex algorithm was fished off the net in Perl 4. I
append below. I saw a recent reference to a Perl 5 soundex module, which
might be a better thing to go for these days.

--
Philip Hazel                   University Computing Service,
ph10@???             New Museums Site, Cambridge CB2 3QG,
P.Hazel@???          England.  Phone: +44 1223 334714



# This function was fished off the net...

# $Id: soundex.pl,v 1.2 1994/03/24 00:30:27 mike Exp $
#
# Implementation of soundex algorithm as described by Knuth in volume
# 3 of The Art of Computer Programming, with ideas stolen from Ian
# Phillips <ian@???>.
#
# Mike Stok <Mike.Stok@???>, 2 March 1994.
#
# Knuth's test cases are:
#
# Euler, Ellery -> E460
# Gauss, Ghosh -> G200
# Hilbert, Heilbronn -> H416
# Knuth, Kant -> K530
# Lloyd, Ladd -> L300
# Lukasiewicz, Lissajous -> L222
#
# $Log: soundex.pl,v $
# Revision 1.2 1994/03/24 00:30:27 mike
# Subtle bug (any excuse :-) spotted by Rich Pinder <rpinder@???>
# in the way I handles leasing characters which were different but had
# the same soundex code. This showed up comparing it with Oracle's
# soundex output.
#
# Revision 1.1 1994/03/02 13:01:30 mike
# Initial revision
#
#
##############################################################################

sub soundex
{
local (@s, $f, $fc, $_) = @_;

  foreach (@s)
  {
    tr/a-z/A-Z/;
    tr/A-Z//cd;


    if ($_ eq '')
    {
      $_ = $noCode;
    }
    else
    {
      ($f) = /^(.)/;
      tr/AEHIOUWYBFPVCGJKQSXZDTLMNR/00000000111122222222334556/;
      ($fc) = /^(.)/;
      s/^$fc+//;
      tr///cs;
      tr/0//d;
      $_ = $f . $_ . '000';
      s/^(.{4}).*/$1/;
    }
  }


wantarray ? @s : shift @s;
}