Skip Menu |

This queue is for tickets about the HTML-TableExtract CPAN distribution.

Report information
The Basics
Id: 31582
Status: new
Priority: 0/
Queue: HTML-TableExtract

People
Owner: Nobody in particular
Requestors: auto218872 [...] hush.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC:
Subject: Problem with column($col) subroutine
Date: Sun, 16 Dec 2007 09:17:15 -0600
To: <bug-HTML-TableExtract [...] rt.cpan.org>
From: <auto218872 [...] hush.com>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This issue affects HTML::TableExtract v2.10 on perl 5.8.8. Copied from perlmonks "HTTP::TableExtract woes" (http://perlmonks.com/?node_id=657275): ==================== 'Ola, monks. I've been having a terrible time using HTML::TableExtract to extract a column from an HTML file using the 'column($col)' subroutine. I'm entirely baffled by this, so I've decided to throw in the towel and let some real professionals take a stab at it. No matter how I use 'column($cols)', I always get a 'row ARRAY(...) out of range (0)' message. I took a peak at the source for HTML::TableExtract, but couldn't determine what's going wrong. Could some benevolent monk show me the way? Relevant links, for the lazy: * HTML::TableExtract @ CPAN * HTML::TableExtract source #!/usr/bin/perl use HTML::TableExtract; use WWW::Mechanize; use Data::Dumper; use strict; use warnings; my $sensational = WWW::Mechanize->new( autocheck => 1 ); $sensational->get('http://www.drudgereport.com/'); chomp(my $html = $sensational->content); my $table = HTML::TableExtract->new(); $table->parse($html); #$table->tables_dump; my $t = $table->first_table_found; #print $t->cell(0,1); # works fine # each of these generate a 'row ARRAY(...) out of range (0)' message #print $t->column(1), "\n"; #print for $t->column(1); #print Dumper $t->column(1); $t->column(1); ==================== And a <a href="http://perlmonks.com/?node_id=657283">reply</a> with a proposed patch: ==================== sub column { my $self = shift; my $c = shift; my @column; - - foreach my $row ($self->rows) { + foreach my $row (0..$#{$self->rows}) { push(@column, $self->cell($row, $c)); } wantarray ? @column : \@column; } Method rows() returns an anonymous array of rows (arrayrefs), but the cell method works with indices. ==================== -----BEGIN PGP SIGNATURE----- Note: This signature can be verified at https://www.hushtools.com/verify Charset: UTF8 Version: Hush 2.5 wpwEAQECAAYFAkdlQXsACgkQzqQCDJ3lRA/3qgP9GZRLCvZAHKvSzgCktRgVcrwJbT8h mDw5G6tQJssEbt2MC3eNnjsvC35FEXGLDLpUk54huM9UkLYxaBu8forNQDA71ZJONDuk qT6Z1j+MIRYsfytf8wlAbyJxCKPkRFbinyLkigUiw0/I3J5X8KPWURurDGWqjfeKC1it 91jE2KY= =452W -----END PGP SIGNATURE----- -- Fast Computer Training. Click here. http://tagline.hushmail.com/fc/Ioyw6h4dFucZxsBQlUVX0Ku9mqupxTa2dmh2EkQDru6VixrroT2zhi/