sub build_consultant_data() { $dbh = DBI->connect("DBI:CSV:f_dir=$CSV_DATA") or die "Cannot connect: " . $DBI::errstr; # Connect to the DB my $directory = $ua->get('http://www.somwhere.com/blah/blah/blah/') ; # Get directory my $te = new HTML::TableExtract( headers => [qw/Name Int Username Group/] ) ; # Set up for TableExtract $te->parse( $directory->content ); # Extract the pertinent data my $ts = $te->first_table_state_found() ; # Create a table_state object to get at the rows $sth = $dbh->prepare( "INSERT INTO $CONSULTANT_TABLE VALUES (?, ?, ?, ?, ?)") or die "Cannot prepare: " . $dbh->errstr(); # Prepare to insert fields. my $i = 0; # Initalize counter foreach my $row ( $ts->rows ) { # Handle all the rows of data next unless @$row[0]; # Dump the row if the real name is empty my ( $ln, $fn ) = split ( /,/, @$row[0] ); # Extract last name $fn = ( split ( / /, $fn, 1 ) )[0]; # Remove middle name $sth->execute( $i++, $fn, $ln, @$row[2], @$row[3] ); } $dbh->disconnect(); # Disconnect from the DB }