> I wonder how Hans Zimmer feels about it ...

I am sure Hans will be cool with it...

> Thanks for the regex though :)

You're welcome. I was working a bit more on this phone number routine (see
http://www.opensrs.org/archives/dev-list/0110/0034.html and
http://www.opensrs.org/archives/dev-list/0110/0035.html ).

I think something like this might work better, based on the phone numbers I
have seen used to register domains here:

sub correct_phonenum_for_dotinfo {
    
    my ($id,$prefix,$new_phone_num);
    
    my ($country_code,$current_phone_num) = @_;
    
    my $cc_prefix;

    open (FILE, "<$PATH_TEMPLATES/phone_numbers") or die "Can't open
$PATH_TEMPLATES/phone_numbers: $!\n";
    while (<FILE>) {
        chomp;
        if (/^(\w{2})\s+(.+)/) {
             $id = $1;
             $prefix = $2;
             if ($id eq $country_code) {
                $cc_prefix = $prefix;
                last;
                } else {
                next;
                }
             }
    }

    my $new_phone_num = $current_phone_num;
    $new_phone_num =~ s/(-|\(|\))/ /g;


        if ($new_phone_num =~ /^\+$prefix/) {
             $new_phone_num =~ s/^\+$prefix/\+$prefix./g;
        }
        elsif ($new_phone_num =~ /^\+\d{1,3}\ +/) {
             $new_phone_num =~ s/(^\+\d{1,3})\ +/$1\./;
             }
        elsif (($new_phone_num!~/^\+/) && ($cc_prefix ne "")) {
             $new_phone_num = "+$cc_prefix.$new_phone_num";
        }
        elsif ($new_phone_num!~/^\+/) {
            $new_phone_num = "+1.$new_phone_num";
        }

    $new_phone_num =~ s/ //g;

   
    close(FILE);
    return $new_phone_num;
}


Then you could use the full regex to test like so:

if (( $domain =~ /\.info/ ) &&
($HTML{owner_phone}!~/^\+\d{1,3}\.\d{1,12}(x\d{1,4})?$/)) {
      $HTML{owner_phone} =
correct_phonenum_for_dotinfo($HTML{owner_country},$HTML{owner_phone});
������������} 

Seems to work fine in my tests... Anyone see a way to do it better or
faster?

-- 
John Keegan
[EMAIL PROTECTED]
http://RackShare.com


Reply via email to