Hi, if I have a input with new lines in it like:
[INFO]
xyz
[INFO]
How can I pull out the xyz part using $
anchors? I tried a pattern like /^\[INFO\]$(.*?)$\[INFO\]/ms
, but perl gives me:
Use of uninitialized value $\ in regexp compilation at scripts\t.pl line 6.
Is there a way to shut off interpolation so the anchors work as expected?
EDIT: The key is that the end-of-line anchor is a dollar sign but at times it may be necessary to intersperse the end-of-line anchor through the pattern. If the pattern is interpolating then you might get problems such as uninitialized $\
. For instance an acceptable solution here is /^\[INFO\]\s*^(.*?)\s*^\[INFO\]/ms
but that does not solve the crux of the first problem. I've changed the anchors to be ^
so there is no interpolation going on, and with this input I'm free to do that. But what about when I really do want to reference EOL with $
in my pattern? How do I get the regex to compile?