in reply to Re^4: (german) region code detection - request for thoughts
in thread (german) region code detection - request for thoughts

  1. Different minimal lengths of region codes
  2. Different maximum lengths of region codes
  3. It sholud find those values on it's own
Update But... it's all there already ?
There are no string comparisons, and the order of look-ups assures that the longest existent key/prefix always win.


Oh, it's not, I just misunderstood your points. But definitely not hard to add, if really needed:
use List::Util; my $min_prefix_length = min keys %prefixes; my $max_prefix_length = max keys %prefixes; my $prefix_length = $max_prefix_length; while ( $prefix_length-- >= $min_prefix_length) { last if exists $prefixes{ substr( $phone, 0, $prefix_length) }; } # Error/inexistent prefix if $prefix_length < $min_prefix_length;
etc.

Krambambuli
---

Replies are listed 'Best First'.
Re^6: (german) region code detection - request for thoughts
by Skeeve (Parson) on Aug 20, 2008 at 15:22 UTC

    Don't get me wrong. I just wanted to point out what was still missing, compared to my approach. I didn't want you to program that for me.

    Nevertheless ++ for your effort!


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e