public
Created

  • Download Gist
servers.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#!/usr/bin/perl
 
use DBI;
use LWP::Simple;
 
 
my $dbh = DBI->connect("dbi:SQLite:dbname=servers.sqlite3","","");
 
{
my $sth = $dbh->prepare("CREATE TABLE servertypes (name varchar(255));");
 
if(defined $sth)
{
$sth->execute();
}
 
}
 
my @hosts=("http://google.com","http://reddit.com","http://digg.com");
 
foreach( @hosts)
{
 
my $host=$_;
 
print "Checking $host ...\n";
my $type=head($host)->server."\n";
 
my $sth=$dbh->prepare("INSERT INTO servertypes VALUES ('$type');");
$sth->execute();
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.