Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Cleaning up HTML tags

by esh (Pilgrim)
on Aug 25, 2003 at 04:36 UTC ( [id://286302]=note: print w/replies, xml ) Need Help??


in reply to Cleaning up HTML tags

At the risk of getting negative votes by not actually answering your question, I'd posit that the functionality of the filter matters much more than the interface, provided that the interface allows you to specify the options you require and provides the results you desire.

It would be trivial to turn the OO interface you list into a procedural interface. It seems to me the important part is how good the logic is inside the package.

Here's some code which takes the OO interface you hate in your first example and lets you call it as the procedural interface you desire in your second example.

package HTML::ProceduralMarkupRemover; sub html_passes_rules { my ($some_html, $html_rules) = @_; my $hsmr = HTML::SomeMarkupRemover->new($html_rules); return $hsmr->passes_rules($some_html); } sub apply_html_rules { my ($some_html, $html_rules) = @_; my $hsmr = HTML::SomeMarkupRemover->new($html_rules); return $hsmr->apply_rules($some_html); } 1;

But why bother?

-- Eric Hammond

Replies are listed 'Best First'.
Re: Re: Cleaning up HTML tags
by cleverett (Friar) on Aug 25, 2003 at 05:18 UTC
    Obviously the functionality is very important. But from what I can see, the modules I mentioned in my original post all pretty much do what I need. HTML::Scrubber and HTML::Sanitizer allowing the user to aqdjust his rules on the fly

    Don't get me wrong: I like objects, a lot.

    It just bugs me when those snappy OO interfaces don't actually contribute expressive power. So, I'm looking for a procedural alternative, that I haven't been able to find on my own.

    Why have the overhead of creating and destroying objects to do such a simple thing? Why do I have to type in that extra line of code?

    As an analogy, who bothers with the OO interface to Digest::MD5 99% of the time? I for one, am so glad the guy who wrote it lets me get by with md5_hex().

      Ok, it sounds like we're both on the same page. I also like to gripe about interfaces of various packages when they don't match how I would design them.

      But, sometimes the functionality is so good, that I put up with a lot of (what I consider to be) strangeness in the inteface. Take <name deleted to protect the guilty> for example, which I love and strongly recommend, just because it does a great job of coming up with results I want.

      -- Eric Hammond

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://286302]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-25 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found