##
#!/usr/bin/perl -w
use strict;
use HTML::TableExtract;
use DBI;
my $te = HTML::TableExtract->new();
$te->parse_file("arbitraryname.html");
my $table = $te->first_table_found;
my @totalrows;
push @totalrows, $_ foreach $table->rows();
my (@title, @teach, @aides);
foreach my $rownum (0..$#totalrows) {
# A cell can be called by $table->cell(row,column)
if ($table->cell($rownum, 0..2) =~ /\xa0/) {
s/\xa0\d+/ /;
} else {
s/\xa0//;
}
push @title, $table->cell($rownum, 0) ? $table->cell($rownum, 0) : '';
push @teach, $table->cell($rownum, 1);
push @aides, $table->cell($rownum, 2) ? $table->cell($rownum, 2) : '';
}
foreach my $ele (0..$#title) {
print "$title[$ele] - $teach[$ele] - $aides[$ele]\n"; # Testing output before I uncomment database section
=for comment
# inserting into a database, etc
=cut
}
####
Boss Firstname Surname Secretary Name Surname, Mr Jones Smith Medical Doctor Bob Middlename Hope Position 1 Worker Secretary Asdf Ghjk Name Lastname, First Last Sally Mally Joe Smoe, The Who, Will Timberland Position 2 Paula Simon Raymonde Maalouf
####
my $dbh = DBI->connect("DBI:mysql:$dbname:$dburl", "$dbuser", "$dbpass") or die "Could not connect";
my $sth = $dbh->prepare("INSERT INTO $dbtable (position, name, email) VALUES (?, ?, ?)") or die "Could not prepare";
$sth->execute($position, $name, $email) or die "Could not execute";
$sth->finish();
$dbh->disconnect;
}