I have the following lines of text in some configuration file, need to parse that file using Perl, find the File:
line and replace its content using some regular expression to add some text etc.
File: logs/${byYearMonth}.log
The problem I have is with the regular expression, because I would like to use ${byYearMonth}.log
in it, as it's easy to read, can easily be quoted etc. But this looks like variable interpolation to Perl and I get the following compilation error for the following simplified reg exp:
... =~ s/...\Q${byYearMonth}.log\E.../.../m;
Global symbol "$byYearMonth" requires explicit package name (did you forget to declare "my $byYearMonth"?)
Of course I can rework the reg exp to not let Perl think it's a variable name, but the provided version above is the most easiest to read and search for in my opinion. Thinking and researching about the problem, I didn't find any solution which would allow me to keep the reg exp as is and prevent the Perl compilation error by only adding some flag or whatever.
So, is there any (easy) way to tell Perl that some plain and already quoted text is not to be interpolated to get rid of the compilation error?
I have the feeling I'm missing something really easy, so thanks for your hints! :-)