#!/usr/bin/perl use strict; use DBI; my $dsn = "DBI:mysql:database=$ENV{DBNAME};host=$ENV{DBHOST}"; my $dbh = DBI->connect ($dsn, $ENV{DBUSER}, $ENV{DBPASS}); die DBI->errstr if !$dbh->do ("show tables"); for ("create table rdns (rdns_ip char(15) primary key)", "alter table rdns add rdns_mono_name varchar(128)", "alter table rdns add rdns_ptr varchar(128)", ) { local $dbh->{PrintError} = 0; $dbh->do ($_); } my $insert = $dbh->prepare ("insert ignore into rdns (rdns_ip) values (?)"); my $update = $dbh->prepare ("update rdns set rdns_mono_name=? where rdns_ip=?"); while(<>) { print STDERR "." if -t STDERR; chop; my ($ip, $name) = split (/\s+/, $_, 2); $insert->execute ($ip); $update->execute ($name, $ip); } print STDERR "\n" if -t STDERR;