Personally I would use HTML::TableExtract which is a subclass of HTML::Parser for everything. If you want a fragile regex solution you could do (assuming html page is in the scalar $html):

my ($location) = $html =~ m/Location:\s*([^<]+)/i; my ($time) = $html =~ m/Time:\s*([^<]+)/i; my ($days) = $html =~ m/Days:\s*([^<]+)/i; my ($instructor) = $html =~ m/Instructor:\s*([^<]+)/i; # if you want plain text you will need to do this $location = unescapeHTML($location); $time = unescapeHTML($time); $day = unescapeHTML($days); $instructor = unescapeHTML($instructor); # this unescapes common cases, not all possible cases. For perfection +-> CPAN sub unescapeHTML { my( $unescape ) = @_; return undef unless defined($unescape); $unescape=~ s[&(.*?);]{ local $_ = $1; /^amp$/i ? '&' : /^quot$/i ? '"' : /^gt$/i ? '>' : /^lt$/i ? '<' : /^nbsp/i ? ' ' : /^#(\d+)$/ ? chr($1) : /^#x([0-9a-f]+)$/i ? chr(hex($1)) : $_ }gex; return $unescape; }

If you use arrays rather than scalars for location et al and add a /g you will get all the locations on the page...

my @location = $html =~ m/Location:\s*([^<]+)/gi; # first match will be in $loction[0] and last match (no suprisingly) i +n $location[-1]

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Best way to search for specifics in a webpage? by tachyon
in thread Best way to search for specifics in a webpage? by Anonymous Monk

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.