http://qs321.pair.com?node_id=11119980


in reply to Re^6: Looking for a module that strips an HTML tag and its associated 'TEXT'
in thread Looking for a module that strips an HTML tag and its associated 'TEXT'

And did you look at my earlier suggestion?

  • Comment on Re^7: Looking for a module that strips an HTML tag and its associated 'TEXT'

Replies are listed 'Best First'.
Re^8: Looking for a module that strips an HTML tag and its associated 'TEXT'
by nysus (Parson) on Jul 29, 2020 at 14:40 UTC

    I looked at Mojo::Dom briefly. It's a general purpose tool. Was hoping for a module that let me knock this out in in like two lines. Mojo::Dom is my fallback plan if I can't find what I'm looking for.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      "Was hoping for a module that let me knock this out in in like two lines."

      Ignoring this many dependant modules and literally thousands of lines of code :P

      my $html = 'url: <a href="http://example.com">http://example.com</a>'; my $dom = Mojo::DOM->new( $html ); say $dom->at('a')->remove;

        Almost, not quite. Need this:

        # strips a specific tag from string sub eliminate_tags { my ($page, $tag) = @_; my $dom = Mojo::DOM->new; foreach my $b ($dom->parse($page)->find($tag)->each) { $b->remove } return $dom; }

        So my beef it that: 1) I'd have to be familiar enough with Mojo::Dom to figure out it could do this (I'm not) so I needed to come PerlMonks to find someone like you to help and 2) I have to spend 20 min. wading through monstrous documentation to figure out how to use it for something simple.

        So why isn't a specific tool better than a general purpose tool? You're saying a specific tool is inferior because it has more dependencies?

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks

        Would it make sense, in your opinion, to create new module that is just a wrapper for Mojo::DOM with a specific use case of deleting nodes with a certain tag and submitting to cpan?

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks