Im fairly new to Perl and Im trying to grab data from a table from a html file I have on my local harddrive. The file is called 'ops_tran_tracking.html' and the columns headers are as follows 'Account Number', 'Fraud Transfer' , etc(see below in my code). What am I doing wrong? I get no errors and nothing prints on my screen. Noticed I put the carriage return after 'Dispute' and after 'After' in the last column because in the HTML file its on the next line. Below is the HTML source code for the file.
<th class=" Header" scope="col">Account Number</th>
<th class="r Header" scope="col">Fraud Transfer<br>Date</th>
<th class="r Header" scope="col">Balance</th>
<th class="r Header" scope="col">No. of Disputes<br>After Transfer</th
+>
<th class="r Header" scope="col">Disputed Dollars After<br>Transfer</t
+h>
Thanks in advance. Below is the Perl code.
#!/usr/bin/perl
use HTML::TableExtract;
$te = HTML::TableExtract->new( headers => [qw('Account umber' 'Fr
+aud Transfer' 'Date' 'Balance'
'No. of Disputes
After Transfer' 'Disputed Dollars After
Transfer')] );
$html_string = 'ops_tran_tracking.html';
$te->parse($html_string);
# Examine all matching tables
foreach $ts ($te->tables) {
print "Table (", join(',', $ts->coords), "):\n";
foreach $row ($ts->rows) {
print join(',', @$row), "\n";
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.