And here's a bit of Perl code that will populate the MySQL table with our log file data by reading it in from STDIN or given on a command line:
#!/usr/local/bin/perl

use DBI;

my $dbh=DBI->connect(qw|DBI:mysql:weblog|);
$dbh->{'RaiseError'};
my $sth=$dbh->prepare(q{INSERT INTO weblog VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)});
while (<>) {
   chomp;
   my @fields=split(/\t/,$_);
   $sth->execute(@fields);
}
$sth->finish;
$dbh->disconnect;
__END__


Slide 14 of 18 Contents
  1 |   2 |   3 |   4 |   5 |   6 |   7 |   8 |   9 | 10
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18
www.arachna.com > Educational Resources > Conference Presentations

spidaman
© 1999-2009 Ian Kallen | Copyright Notice