whoisearth
whoisearth

Reputation: 4170

Unescaped left brace in regex is deprecated, passed through in regex

I'm working on migrating some legacy code, and Perl is having a fit on the following lines:

$message =~ s/_WIP_list{file}_/$WIP_list{$file}/g;
$message =~ s/_STD_list{file}_/$STD_list{$file}/g;

How should I be writing them to avoid the deprecation error?

Upvotes: 2

Views: 1166

Answers (1)

toolic
toolic

Reputation: 62083

Escape the left brace with a backslash:

$message =~ s/_WIP_list\{file}_/$WIP_list{$file}/g;
$message =~ s/_STD_list\{file}_/$STD_list{$file}/g;
#                      ^

To help debug problems like this, you can add the following to get a more detailed explanation of the warning message:

use diagnostics;

Upvotes: 5

Related Questions