Hi List, I have a script that takes input ( Formatted: +1########## ). What it does with the input is read thru a database table and try to find a match. Here is an example to help clarify this:
+----------------------+------------------------------------------+ | alias | sendto | +----------------------+------------------------------------------+ | +131489804[0-7][0-9] | sip:[EMAIL PROTECTED] | +----------------------+------------------------------------------+ The input is first matched to the 'alias' column. So in this case, +13148980555 would match (because of the regex). After the script finds a match, it returns the 'sendto' column. Does anyone know how to get the script to expand the $1 variable? Is it even possible? I've toyed with it for a while, and can't get it right. Any help is greatly appreciated. Also, from a "Good idea, Bad idea" point of view... If this were to be run approximately 100 times a second searching over 10000 lines in the DB, would it pose a problem processor-wise? Is there a better way to go about this? Again, any and all help is greatly appreciated. Here is the code that I have so far: #!/usr/bin/perl use strict; use warnings; use DBI; my @DBIconn = qw(DBI:mysql:ser:bunsen.netlogic.net ser ftff39b); my $dbh = DBI->connect(@DBIconn) or die "Couldn't connect to database: " . DBI->errstr; my $uri_to = $ENV{'SIP_HF_TO'}; print "Type in a qualified number:\n"; $uri_to = <>; chomp $uri_to; $uri_to =~ m/(\+1\d\d\d\d\d\d\d\d\d\d)/ ; my $sth = $dbh->prepare("SELECT alias, sendto FROM aliases2") or die "Couldn't prepare statement: " . sth->errstr; $sth->execute(); my $i = 0; my @data; if ($sth->rows == 0) { exit -1; } while (@data = $sth->fetchrow_array) { if ($uri_to =~ m/(\+$data[0])/) { print "Matches!\n"; print "\tForwarding to: $data[1]\n"; } else { print "No Match\n"; } } __END__ Thanks, Dave Kettmann NetLogic 636-561-0680 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>