Second Reply - Following Update

I'm detecting either a misunderstanding or a lack of knowledge regarding the way Perl represents object references. This may help:

my $q = CGI->new; print $q; # outputs CGI=HASH(0xhhhhhhh) my $fh = IO::File->new; print $fh; # outputs IO::File=GLOB(0xhhhhhhh) # Format is: # <module-name>=<blessed-reference-type>(0x<hex-memory-location>)

Most HTML::Parser methods return an HTML::Parser object. This is what you are outputting. You'll need to supply code in order for me to supply more information :-)

I haven't used this module previously so I wrote a test script to see what's going on. I've posted it after the 'Read more ...', hopefully you'll find something useful there.

The HTML::Parser documentation includes about half-a-dozen example (working) scripts.

Here's my test script:

!#/usr/bin/perl -w use strict; use HTML::Parser (); my $html = q( <html> <head> <title>The Title</title> </head> <body> <h1>Heading 1</h1> <p>First paragraph.</p> <p><em>Second fully emphasized paragraph.</em></p> <p>Third <em>partially paragraph.</em></p> <p>Para with <strong>BOLD</strong> middle bit.</p> <p>Para with <tt>CODE - changed to TT for PM</tt> middle bit.< +/p> <ul> <li>dot point 1</li> <li>dot point 2</li> <li>dot point 3</li> </ul> </body> </html> ); my $ra_want_tags = [ qw(title h1 p em li strong) ]; my %parser_init = ( api_version => 3, text_h => [\&print_element, 'self'], report_tags => $ra_want_tags, ); my $p = HTML::Parser->new(%parser_init); do { $p->parse($html) } until ($p->eof); sub print_element { my $p = shift; $p->handler(start => sub {print map {s/^<(.+?)>$/$1: /; $_} @_}, 'text'); $p->handler(text => sub {print map {s/^\s*(.*?)\s*$/$1\n/; $_} grep /\S/, @_}, 'dt +ext'); }

PN5


In reply to Re: Re: Re: RobotUA not working by Prior Nacre V
in thread RobotUA not working by mkurtis

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.