use Modern::Perl;
use WWW::Mechanize;
use HTML::TableExtract;
my ( %hash, @company, @country );
my $mech = WWW::Mechanize->new();
$mech->get('http://www.w3schools.com/sql/default.asp');
my $html_string = $mech->content();
my $te = HTML::TableExtract->new( headers => [ ( 'Company', 'Country' ) ] );
$te->parse($html_string);
for my $ts ( $te->tables ) {
for my $row ( $ts->rows ) {
push @company, qq|'$row->[0]'|;
push @country, qq|'$row->[1]'|;
}
}
$hash{'Company'} = '(' . ( join ', ', @company ) . ')';
$hash{'Country'} = '(' . ( join ', ', @country ) . ')';
say "$_ => $hash{$_}" for sort keys %hash