As you say, @$row is an array; but I won't know what the element number is going to be from run to run.

You have a pretty deep misunderstanding of the code you are using. $table->rows() returns a list of arrays. Ie. $row is an array reference representing the fields (or columns) of each row of the table.

So whilst the position (row number) of the row containing the text Ships in port or not reporting today: will vary from run to run. The field or column within that row that contains the text will not.

I used the following code to dump all the tables from the url you posted in another thread to the screen, with '|' between each element of the rows:

#! perl -slw use strict; use LWP::Simple; use HTML::TableExtract; my $te = new HTML::TableExtract; $te->parse( get( 'http://www.sailwx.info/shiptrack/cruiseships.phtml' +) ); for my $table ( $te->tables ) { print "\n-----------\n"; for my $row ( $table->rows ) { local $^W; print join '|', @$row; } }

Redirecting the output of that, junk | more, I got:

... ----------- Ship|last reported (UTC)|position|Callsign BATFR20|2008-Mar-20 2100|N 43░00', E 005░36'|BATFR20 BATFR21|2008-Mar-20 2100|N 41░36', E 008░24'|BATFR21 BATFR22|2008-Mar-20 2100|N 42░54', E 005░54'|BATFR22 ... Carribean Princess|2008-Mar-19 0600|N 19░18', W 065░18'|ZC +DG8 Prinsendam|2008-Mar-19 0300|N 27░24', W 040░24'|PBGH Ships in port or not reporting today:||| TUSTUMENA|2008-Mar-18 1700|N 60░48', W 147░12'|WNGW Oosterdam|2008-Mar-18 0800|N 23░00', W 107░48'|PBKH ...

From the empty fields on the end of Ships in port or not reporting today:|||, I can tell that the text that marks the transition from those ships at sea, to those in port, is returned in $row->[ 0 ].

So your test becomes:

... for my $row ( $table->rows ) { if( $row->[ 0 ] ne 'Ships in port or not reporting today:' ) { ...

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^6: Setting flags in a conditional by BrowserUk
in thread Setting flags in a conditional by mcoblentz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.