It looks like you need to go through some tutorials. I like perldoc perlrequick and perldoc perlretut. Some comments on your code, in no particular order:
  • If you want only the second . to be allowed to match a newline, but not the first, you can set the s flag for just a part of your regex: m/.*INT8U(?s:.)\)/
  • If you want the match to begin at the beginning of the line that has INT8U, use ^ and the m flag: m/^.*INT8U.../m. Without //m, ^ matches only at the beginning of the string, not on interior newlines.
  • m// only checks if part of $Hap matches, it doesn't alter $Hap. To get the part of $Hap that matched, use $& (only after testing that the match was successful) or assign it from the match: if (($match) = $Hap =~ m/.../). (That will get the whole match as long as your pattern has no capturing parentheses.)
  • It sounds as if you have experimented with reading a line at a time or the whole file at a time via undef $/. A line at a time isn't going to work if you need results from more than one line (as it sounds as if you do). See above for getting just the matched part when reading the whole file. If you need to get multiple matches out of the whole file, use a while loop and the //g flag: while ($Hap =~ m/.../g) { print $& }

    I hope at least some of this helps you along.


    In reply to Re: Trouble matching more than one line by ysth
    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.