Hi, am am having a problem with extracting all the data I want using a perl script the data being in a mysql database. The script works fine until row 59101 is reached in the 1st table, anyone aware of any limitations? The database is an ip geo laction database to be found at www.hostip.info. I am using active perl, the db is on my local xp laptop
thanks
Guy
Here is the script:
[code=perl]
#!/usr/local/bin/perl
use strict;
use warnings;
use DBI;
my $num=226;
my $dbh = DBI->connect("dbi:m ysqlPP:database =iplocation:hos t=localhost","r oot","********* ",{'RaiseEr ror' =>1});
my @ranges = $dbh -> tables;
open(my $out, ">", "output.txt ") or die "Can't open output.txt: $!";
for(my $i=2; $i<(@ranges); $i++)
{
my $sth = $dbh -> prepare (qq{select * from $ranges[$i] where country = $num});
$sth -> execute ();
print "checking table $ranges[$i]\n";
while (my $ref = $sth->fetchrow_array ref())
{
print $out "IP address is $ranges[$i].$ref->[0].$ref->[1]\n";
$sth->finish();
}
}
close $out or die "$out: $!";
$dbh->disconnect ();
[/code]
_______________
Here is the last entry in output.txt where the code hangs:
$ tail output.txt
IP address is ip4_0.255.212
IP address is ip4_0.255.213
IP address is ip4_0.255.214
IP address is ip4_0.255.215
IP address is ip4_0.255.216
IP address is ip4_0.255.217
IP address is ip4_0.255.218
IP address is ip4_0.255.219
IP address is ip4_0.255.220
IP ad
What is strange is that it doesn't complete the print of IP address is
thanks
Guy
thanks
Guy
Here is the script:
[code=perl]
#!/usr/local/bin/perl
use strict;
use warnings;
use DBI;
my $num=226;
my $dbh = DBI->connect("dbi:m ysqlPP:database =iplocation:hos t=localhost","r oot","********* ",{'RaiseEr ror' =>1});
my @ranges = $dbh -> tables;
open(my $out, ">", "output.txt ") or die "Can't open output.txt: $!";
for(my $i=2; $i<(@ranges); $i++)
{
my $sth = $dbh -> prepare (qq{select * from $ranges[$i] where country = $num});
$sth -> execute ();
print "checking table $ranges[$i]\n";
while (my $ref = $sth->fetchrow_array ref())
{
print $out "IP address is $ranges[$i].$ref->[0].$ref->[1]\n";
$sth->finish();
}
}
close $out or die "$out: $!";
$dbh->disconnect ();
[/code]
_______________
Here is the last entry in output.txt where the code hangs:
$ tail output.txt
IP address is ip4_0.255.212
IP address is ip4_0.255.213
IP address is ip4_0.255.214
IP address is ip4_0.255.215
IP address is ip4_0.255.216
IP address is ip4_0.255.217
IP address is ip4_0.255.218
IP address is ip4_0.255.219
IP address is ip4_0.255.220
IP ad
What is strange is that it doesn't complete the print of IP address is
thanks
Guy
Comment