6 @EXPORT = qw(&soundex $soundex_nocode);
8 # $Id: soundex.pl,v 1.2 1994/03/24 00:30:27 mike Exp $
10 # Implementation of soundex algorithm as described by Knuth in volume
11 # 3 of The Art of Computer Programming, with ideas stolen from Ian
12 # Phillips <ian@pipex.net>.
14 # Mike Stok <Mike.Stok@meiko.concord.ma.us>, 2 March 1994.
16 # Knuth's test cases are:
18 # Euler, Ellery -> E460
19 # Gauss, Ghosh -> G200
20 # Hilbert, Heilbronn -> H416
23 # Lukasiewicz, Lissajous -> L222
25 # $Log: soundex.pl,v $
26 # Revision 1.2 1994/03/24 00:30:27 mike
27 # Subtle bug (any excuse :-) spotted by Rich Pinder <rpinder@hsc.usc.edu>
28 # in the way I handles leasing characters which were different but had
29 # the same soundex code. This showed up comparing it with Oracle's
32 # Revision 1.1 1994/03/02 13:01:30 mike
36 ##############################################################################
38 # $soundex_nocode is used to indicate a string doesn't have a soundex
39 # code, I like undef other people may want to set it to 'Z000'.
41 $soundex_nocode = undef;
47 # @codes = &soundex (@wordList);
48 # $code = &soundex ($word);
50 # This strenuously avoids 0
54 local (@s, $f, $fc, $_) = @_;
68 tr/AEHIOUWYBFPVCGJKQSXZDTLMNR/00000000111122222222334556/;
78 wantarray ? @s : shift @s;