Well, there are different ways that you can do this, but they all revolve around one central point: you need to define how much context you are interested in searching.

If, as you say, you just undef $/, meaning, I assume, that you read an entire file into $Hap, then your regular expression is too broad. You have .* before and .* after the key bit of text... this means that you'll be matching the entire file. (Even if you limited the regular expression, though, you're printing $Hap, not printing just the portion of the string that matched the regexp.)

In order to handle that properly, you'd want to be clear in your regular expression where you wanted to begin your match... like maybe: /void .*?INT8U.*?\)/. Also, you'd want to capture the match: /(void .*?INT8U.*?\))/ and then reference the captured text: print $1;.

Anyway, another entirely different way to deal with it is to use the same regular expression, but set $/ to an appropriate value, so that you split your input into the chunks that you are interested in. Maybe, for example, by setting $/ to "\n\n". That would break up your input into paragraphs (which may or may not be what you want). Anyway, I can't really tell more, because your question is a little vague.


------------
:Wq
Not an editor command: Wq

In reply to Re: Trouble matching more than one line by etcshadow
in thread Trouble matching more than one line by Levan

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.