in reply to Re: Global Modifier on a Pattern -- HOW!?!?!?
in thread Global Modifier on a Pattern -- HOW!?!?!?

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!

  • Comment on Re^2: Global Modifier on a Pattern -- HOW!?!?!?