if I have input with new lines in it, for example:
[INFO]
xyz
[INFO]
How can I pull out a piece of xyz with anchors $? I tried a type template /^\[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 disable interpolation so that the anchors work as expected?
EDIT: The key is that end-of-line binding is a dollar sign, but sometimes you may need to interpolate end-of-line binding through a pattern. If the template is interpolated, then problems can occur, such as uninitialized $\. For example, an acceptable solution here /^\[INFO\]\s*^(.*?)\s*^\[INFO\]/ms, but it does not solve the essence of the first problem. I changed the anchors to ^, so there is no interpolation, and with this input I can do it. But what about when I really want to reference EOL with help $in my template? How to get a regex for compilation?
source
share