An Improved Extraction Routine
my @col_names = qw(first_name surname ext ddi mobile email);
sub get_phonelist_data {
my $dom = get_phonelist_html();
my @results;
foreach my $row ($dom->findnodes('//tr')) {
my @f = map {
$_ = $_->to_literal;
s/\x{A0}/ /sg; # => space
s/^\s+//g; # strip leading space
s/\s+$//g; # strip trailing space
s/\s\s+/ /g; # collapse spaces
$_;
} $row->findnodes('./td');
next if(@f != @col_names or $f[-1] !~ /@/);
my %rec;
@rec{@col_names} = @f;
push @results, \%rec;
}
return \@results;
}