I'll preface this post by saying I haven't used perl in a few years and that was simply for an undergraduate web programming class. Currently I am trying to parse out data from SEC financial statements, which can be found in tables. I'll need to be searching through 200k+ documents and wanted a way to loop through a list of urls quickly. I can correctly get the array of urls set up, but trying to use html::tableextract for each item of the array is proving troublesome. Any suggestions would be greatly appreciated. Code is below:
#!/usr/bin/perl use 5.014; # so push/pop/etc work on scalars (experimental) use strict; use warnings; use LWP::Simple 'get'; use HTML::TableExtract; my $file = 'C:\Payout Policy Paper\Data\urllist.csv'; open (FH, "< $file") or die "Can't open $file for read: $!"; my @lines = <FH>; close FH or die "Cannot close $file: $!"; print @lines; foreach $line (@lines) { my $te = HTML::TableExtract->new( headers => [ 'Purchased','Average','Publicly','May'], slice_columns => 0,keep_html => 0,br_translate => 0 ); $te->parse($line); my $table = $te->first_table_found; use Data::Dump; dd $_ for $table->rows; }
I receive the error: Global symbol "$line" requires explicit package name at c:perlscripts\test.pl
Update 1: Thank you both for the quick responses, that moves me further along in the code, but the error I now receive is "Can't call method "rows" on an undefined value at C:\perlscripts\test.pl line 31"
In reply to Foreach Array and Html table extract by doctordoctor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |