Perl search/replace cannot find the regex
I have a python program which I want to modify using Perl, at each run. Somehow the expressions I want to replace are not found at all.
Here are code snippets:
i open the python script and read all the lines with
my @lines=<$INFILE>
Then
if($line =~ m/dfmx=df[['\d{4}', 'Mean', '\d{4}']].max(axis=1)/){
$line =~ s/dfmx=df[['\d{4}', 'Mean', '\d{4}']].max(axis=1)/dfmx=df[['$year1', 'Mean', '$year2']].max(axis=1)/g;
}
if($line =~ m/plt.plot(dfdi[1], df['\d{4}'], color="g", label="\d{4}")/){
$line =~ s/plt.plot(dfd[1], df['\d{4}'], color="g", label="\d{4}")/plt.plot(dfd[1], df['$year1'], color="g", label="$year1")/g;
}
I have defined year1 and year2 before these lines.
I am really baffled that these lines cannot be seen at all. When I put a print statement after the “if”, nothing happens.
I have tried to escape all occurences of [ and ], nothing happens.
any ideas pleas!
Read more here: Source link
