OK, it looks like I confused "{32760}" and "{234565}"; however, I don't see "{234565}" anywhere in your code, although you state:

"... when I come to the part "RFC822.TEXT {234565}" I now need to read exactly 234565 from the string."

The string data you posted is multi-line (i.e. it contains newlines) so you'll need the 's' modifier if you want '.' to match newlines as well as other characters (see perlre: Modifiers). Here's a rough example of what I think you're looking for:

$ perl -wE 'my $x = qq{abcd\nefgh\nijkl}; say ">$x<"; say ">$1<" while + $x =~ /(.{3})/gs' >abcd efgh ijkl< >abc< >d e< >fgh< > ij<

[Note how I've wrapped each string in angle brackets, so that you can see not just the start and end of each string, but also the placement of newlines within them.]

The caret (in your original code) still looks dubious. If it isn't, and you want to match the start of lines (in a multi-line string), you'll need the 'm' modifier (see perlre: Modifiers). Also, if you want to match the start of the entire string, use '\A' (see perlre: Assertions).

— Ken


In reply to Re^3: Matching n characters with m//g by kcott
in thread Matching n characters with m//g by medium.dave

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.