Fixed the telcodata_lookup subroutine to properly handle an invalid request: sub telcodata_lookup { my ($npa, $nxx) = @_; my $req = get('http://www.telcodata.us/query/queryexchangexml.html?npa=' . $npa . '&nxx=' . $nxx); if (defined $req) { my $res = $xml->XMLin($req); if ($res->{exchangedata}->{validnumeric} eq "1") { my $clidname = '* ' . $res->{exchangedata}->{ratecenter} . ', ' . $res->{exchangedata}->{state}; return $clidname; } } return ""; }