#!/usr/bin/perl use DBI; open(INFILE, "/usr/share/cid/callerid.txt") or die "cannot open file"; if ($callerID=) { my $dbh = DBI->connect ("dbi:mysql:host=alice:database=asterisk","asterisk","password") or die "Can't connect to database: $DBI::errstr "; my $sth = $dbh->prepare( "SELECT cid FROM known_numbers WHERE source='$callerID'" ); $sth->execute(); @row = $sth->fetchrow_array(); print "SET CALLERID "@row"<$callerID>"; } close INFILE;