[Dub-pm] Phone numbers

David Cantrell david at cantrell.org.uk
Tue Oct 19 10:58:05 CDT 2004


On Tue, Oct 19, 2004 at 04:00:30PM +0100, Fergal Daly wrote:
> On Tue, Oct 19, 2004 at 03:21:29PM +0100, David Cantrell wrote:
> > Look at the source for N::P::Country, and how he handles the craziness
> > that is +1.  I'd handle +353 the same way.  And +7, +34, and +39.
> That certainly does look crazy.

+1 is just a silly idea.  Pity that the NANP countries' phone systems
are so backward that they can't realistically upgrade to something that
makes sense :-)

> I did this a few years ago and I did what you're doing, see if the whole
> number matches, then chop off the last number and try again, then chop off
> and try again... I also tried building a trie (although I didn't know it at
> the time).

Yes, that works too.

>                      I know someone working for a telco who implemented his
> tries in C which was much more efficient, time and space-wise but he can't
> release the code,

The technique that I use (given 123456789, first look for 123456789,
then for 12345678, then 1234567 and so on until you get a match) was
certainly quick enough that I could switch a call - using perl* and
mysql! - in hundredths of a second.  OK, admittedly we cheated by skipping
a chunk in the middle.  Given a number like 0ABCDEFGHIJ we'd look up the
whole number, then go straight to 0ABCDEF cos we knew that the intervening
digits weren't significant, as the smallest block assigned to us was
10000 numbers. [yes, I've simplified international calls out of this]

When I was using similar code for billing, I used the same technique,
but the time taken was negligible compared to the database lookups
required to figure out tariffs.  In the worst case I could still bill
calls 30 times faster than customers were making them, on pretty low
endian hardware.

* a couple of years ago I worked for a telco which used perl for pretty
much everything

-- 
David Cantrell | Reality Engineer, Ministry of Information

  attractivating: inducing the quality of being attractive,
     especially to members of the appropriate sex.  -- Henrik Levkowetz


More information about the Dublin-pm mailing list