BrowserUK suggested an elegant solution but you've hit two snags.

Parsing HTML is tricky and feature creep!

The following snippet uses an HTML parser to do the heavy lifting.

#!/bin/perl5 use strict; use warnings; use HTML::TokeParser::Simple; my $html; { local $/; $html = <DATA>; } my $p = HTML::TokeParser::Simple->new(\$html); my ($start, @data); while (my $t = $p->get_token) { $start++, next if $t->is_comment and $t->as_is eq '<!--begin-->'; last if $t->is_comment and $t->as_is eq '<!--end -->'; next unless $start; if ($t->is_start_tag('b')){ my $comment = $p->get_trimmed_text('/b'); my $sig = $p->get_trimmed_text('hr'); $sig =~ s/\s+-.*//; # crudely strip the timestamp push @data, join '|', $sig, $comment; } } print "$_\n" for @data; __DATA__ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML><HEAD><META http-equiv="Content-Type" CONTENT="text/html; charse +t=iso-8859-1"> <TITLE>Last Post </TITLE></HEAD> <BODY> <!--begin--> <HR> <b>Comment 1</b><br> Doug &lt;<a href="mailto:hun@tele.com">hun@tele.com</a>&gt;<br> USA - Thu 01/05/2006 - 22:05:51 <hr> <b>Comment 2</b><br> J H<br> Clearwater, FL USA - Wed 01/04/2006 - 02:05:12 <hr> <!--end --> </BODY></HTML>
output:
---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" _new.pl Doug <hun@tele.com> USA|Comment 1 J H Clearwater, FL USA|Comment 2 > Terminated with exit code 0.

Hope this helps.


In reply to Re: Search function for guestbook history? by wfsp
in thread Search function for guestbook history? by JCHallgren

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.