Reputation: 21
I'm a novice programmer. I have around 100 html files and from each file I have to extract data from different rows and store separately. I wrote the following code, some one please help me figure out the flaws.
#!/usr/bin/perl -w
use strict;
use warnings;
use HTML::TableExtract ;
my$te = HTML::TableExtract->new(headers => [qw('Compound' 'Name' 'Adduct' 'Adduct MW (Da)' 'Compound MW (Da)' 'Delta')]) ;
my @files = </home/akhila/sta/hmdb_hits/com_pks_stn/*.html>;
foreach my $files(@files){
$te ->parse_file($files) or die "cannot parse file";
foreach my $ts ($te->table()){
print "Table(", join(',', $ts->coords),"):\n";
foreach my$row($ts->rows()){
print join(',', @$row), "\n";
}
}
}
Upvotes: 1
Views: 357
Reputation: 63912
You need read about how the quota like operators works in perl. Try the next code and you will immediatelly see the problem.
use strict;
use warnings;
use Data::Dumper;
use HTML::TableExtract;
my $te1 = HTML::TableExtract->new(headers => [qw('Compound' 'Name' 'Adduct' 'Adduct MW (Da)' 'Compound MW (Da)' 'Delta')]) ;
print Dumper $te1->{headers};
my $te2 = HTML::TableExtract->new(headers => ['Compound', 'Name', 'Adduct', 'Adduct MW (Da)', 'Compound MW (Da)', 'Delta']) ;
print Dumper $te2->{headers};
Upvotes: 1