While I entirely sympathise with the sentiment (ie you wanna use it as a vehicle to learn) I (and no doubt the vast bulk of the monastery) would strongly advise you not to.
The reason is that quite simply that parsing HTML is a non-trivial act. Further there are a variety of power modules available to you to do this, all of which will require you to learn stuff. Stuff which will in the long term be of far more use than learning how to parse HTML.
But in the interest of fair play I will say that
Might do what you want if the HTML is very simple.my $start = quotemeta '<!-- resultItemStart -->'; my $end = quotemeta '<!-- resultItemEnd -->'; my $string =~ m/$start(.*?)$end/s;
Oh yes. For all intents and purposes you should assume that writing code not under strict and warnings is a crime and should be avoided at all costs...
HTH
UPDATE: Just realized I originally posted this with a dreaded .* which is a bad move. Take a look at Death to Dot Star! for why. However derekses use of .+? actually isnt good either, as it will skip an empty "record" instead of reporting it. I believe that .*? is the correct choice here. Oh and I did not capture the $start and $end because you already know what they are, dont you? :-)
Yves / DeMerphq
--
When to use Prototypes?
In reply to Re: pattern matching
by demerphq
in thread pattern matching
by silent11
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |