in reply to How do I select text between two bits of text?

If you are attempting to parse HTML then you'll probably save yourself a lot of time by using one of the HTML modules from CPAN. Depending on what you are trying to achieve, it may be that HTML::TreeBuilder will do the trick for you.

If you are generating the HTML being parsed yourself then maybe it is sufficiently regular that you can get away with using simple regular expressions. But being able to parse wild HTML is a difficult task best left to long in the tooth modules with appropriate experience for the job.

True laziness is hard work
  • Comment on Re: How do I select text between two bits of text?

Replies are listed 'Best First'.
Re^2: How do I select text between two bits of text?
by educated_foo (Vicar) on Dec 04, 2011 at 13:14 UTC
    If you are attempting to parse HTML then you'll probably save yourself a lot of time by using one of the HTML modules from CPAN.
    You *might* save time. Or you might waste a bunch of time (1) figuring out which of a multitude of modules suits you; (2) learning your chosen module's horrible, baroque API; (3) realizing that your HTML is too lax (or invalid) for your chosen module to parse. If it's machine-generated and you just want to pull out something simple, stick with your regex.

      As the sig says "True laziness is hard work". Often the hardest part is figuring out the laziest option. In the context of parsing HTML, and especially if it's not a one off, learning one of those nasty APIs is by far the laziest option.

      True laziness is hard work