in reply to RFC: HTML::TokeParser::Easy

that's pretty easy to use, buuut

a request

I'd also like a get_hashtoken method, wich would return a hashref token, that'd look someting like:

$VAR1 = { 'type' => 'S', # or T|E|C|D|PI 'tag' => 'html', 'attr' => {}, 'attrseq' => [], 'text' => '<HTML>', };
so then I could do
my $token = $parser->get_hashtoken(); if($token->{type} eq 'S') { if(exists $token->{attrs}->{href}) { print Data::Dumper::DumperX($token); } }
still no array indices to remember, and less methods ;)

Also, please get rid of the autoload magic, you're not Lincoln Stein (it is unneccessary, you don't have that many methods like CGI.pm, and it slows things down, please .. if your arms are cramping up, i'll volunteer to do the typing).

update: on the AUTOLOAD issue, I too want to ask "Anyone else think that the AUTOLOAD should go?"

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Replies are listed 'Best First'.
(Ovid) Re: (2): RFC: HTML::TokeParser::Easy
by Ovid (Cardinal) on Mar 02, 2002 at 03:25 UTC

    Hey, the hash functionality looks interesting. I'll keep that in mind. I'll look at how it's organized now to see how I could implement that.

    As for the AUTOLOAD, I'm typically a B&D programmer. The only reason I chose that route is to make maintenance easier. Once it is structured correctly, if more stuff is added to HTML::TokeParser, I just add it to the hash and the methods are auto-generated. If people think that this is too serious an objection, I can take it out.

    As for AUTOLOAD slowing things down, I don't think it does (though I haven't benchmarked it). In my experience, people really only use a few of the array elements from HTML::TokeParser. In this module, those elements translate to methods and once generated, they are added to the symbol table and the overhead is gone. Even if you called every method generated, you would probably add less than a second to the total runtime of the program (and if you called every method, than you have a huge program and that second is meaningless).

    Anyone else think that the AUTOLOAD should go?

    Cheers,
    Ovid

    P.S.: Thanks for the feedback :)

    Update: Now that I think about it, the AUTOLOAD can be simplified by having the two overloaded (is_(start|end)_tag) functions moved into their own methods. Everything else is identical, though. Hmm... maybe it should go.

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.