I am trying to print all the HTML tables containing the string "kcat" for each xml file in a directory but I am having some trouble. Note that each file in the directory (named kcat_tables) has at least one HTML table with kcat in it. I am running this program on an ubuntu virtual machine. Here is my code:
#!/usr/bin/perl
use warnings;
use strict;
use File::Slurp;
use Path::Iterator::Rule;
use HTML::TableExtract;
use utf8::all;
my @papers_dir_path = qw(/home/bob/kinase/kcat_tables);
my $rule = Path::Iterator::Rule->new;
$rule->name("*.nxml");
$rule->skip_dirs(".");
my $xml;
my $it = $rule->iter(@papers_dir_path);
while ( my $file = $it->() ) {
$xml = read_file($file);
my $te = HTML::TableExtract->new();
$te->parse($xml);
foreach my $ts ( $te->tables ) {
if ( $ts =~ /kcat/i ) {
print "Table (", join( ',', $ts->coords ), "):\n";
foreach my $row ( $ts->rows ) {
print join( ',', @$row ), "\n";
}
}
}
}
Any ideas on how I should fix this? Thanks in advance! Also, I am fairly new to the PERL language so a simple, comprehensible answer would be very much appreciated.