monks, my goal is to grab a web page, go through the HTML, match something on one line, grab the next five lines including the one that matched and parse those in order to construct and send an email. Grabbing the page, making the match, parsing the results and sending the email I know how to do (or, at least, I have done bfore (; ). My trouble is telling my program to match the one line, and then grab exactly four more, and then stop. I have no code to post as of yet - just playing with pseudo-code so far for this. I was thinking I could set a varible something like a counter, make it true on the first match, and then short circuit the loop when it hits five, but doing that is not happening for me.

am i on the right track? Should I be doing something else here?

-- I'm a solipsist, and so is everyone else. (think about it)

p.s. this is sort of an exercise for me to learn the LWP module and more about regex - I'm sure there are a million modules which would do all this for me, but that wouldn't really teach me a darned thing now would it? :)


In reply to grabbing N lines after matching one? by jptxs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.