Thanks for your comments. I did read the perldocs a couple of times through before I posted and was aware of the syntax for qr(), including it not supporting the '/g' modifier.

I guess I'm so used to there being "more than one way to do it in perl" that I was baffled when I came across a situation where there wasn't even that one :)

I am aware that I can do it at runtime as in my example. However, what I am attempting to accomplish is to discover a method whereby I can specify a single pattern to:

The idea being is that I have a bunch of lines, of which many (most) _are not_ the line I want (ie. they don't have the marker part) but all of them would otherwise correspond to the rest of the expression to pull out the multiple data items (see my example). For my purposes, I _only_ want to extract the multiple data items from the line that matches the marker.

As you can see in my example, I found a way to do it with a regex, but as it turns out I cannot precompile that regex. And, as this is a snippet from a larger bit of code-- as you might have guessed, I really need for it to be able to be expressed as a single pattern string.

However, from the nature of the replies here, I'm thinking that perhaps the best way is to encode the need for a '/g' modifier into the string (or else something related)-- and then do some quick pre-processing in my code to direct it to execute either with, or without the '/g' modifier.

Thanks all for suggestions and comments. I love coding in perl!


In reply to Re^2: Global Modifier on a Pattern -- HOW!?!?!? by bratwiz
in thread Global Modifier on a Pattern -- HOW!?!?!? by bratwiz

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.