For comparison, this uses
HTML::TreeBuilder.
You have nine groups of seven rows so we process seven rows at a time loading the data into an AoH. I think it reads fairly well and maintaining it ought to be relatively straight forward if your HTML changes.
#! /usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use HTML::TreeBuilder;
my $file_name = q{la.html};
my $t = HTML::TreeBuilder->new_from_file($file_name)
or die qq{cant build tree from *$file_name*: $!};
my @trs = $t->look_down(_tag => q{tr});
my @db;
while (@trs){
my @fields = splice(@trs, 0, 7);
my %rec;
$rec{group} = $fields[0]->as_text;
$rec{type} = $fields[1]->as_text;
my @tds;
@tds = $fields[2]->look_down(_tag => q{td});
$rec{level} = $tds[1]->as_text;
for my $field (3..5){
@tds = $fields[$field]->look_down(_tag => q{td});
$rec{$tds[0]->as_text} = $tds[1]->as_text;
$rec{$tds[2]->as_text} = $tds[3]->as_text;
}
$rec{note} = $fields[6]->as_text;
push @db, \%rec;
}
print Dumper \@db;
extract and the note field shortened for brevity:
$VAR1 = [
{
'Saving Throw:' => 'None',
'Casting Time:' => '1',
'Area of Effect:' => ' 10 ft.×10 ft./level path',
'Range:' => 'Touch',
'Duration:' => '3 rds. + 2 rds./level',
'note' => ' By means of this spell... or mica.',
'Components:' => 'V, S, M',
'group' => 'Detect Illusion',
'level' => '1',
'type' => '(Divination)(Mentalism)'
},
{
'Saving Throw:' => 'Special',
'Casting Time:' => 'Special',
'Area of Effect:' => 'Script reader',
'Range:' => 'Touch',
'Duration:' => '1 day/level',
'note' => ' This spell enables the ....',
'Components:' => 'V, S, M',
'group' => 'Illusionary Script',
'level' => '3',
'type' => '(Illusion/Phantasm)'
},
# ... <snipped>
];
Oh, and btw, 38 lines. :-)