14

I’m not an expert in regex and can't figure what I am supposed to change here.

I get these two errors

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^(.*?)(\\)?\${ <-- HERE ([^{}]+)}(.*)$/ at /usr/share/perl5/Debconf/Question.pm line 72.

Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^}]+)}/ at /usr/share/perl5/Debconf/Config.pm line 30.

When I jump to the line 72 this is what I see

while ($rest =~ m/^(.*?)(\\)?\${([^{}]+)}(.*)$/sg) {
Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
  • 5
    Let me just guess because you are missing any useful context: you are using a newer Perl version on your system then the one which came with the system and now you are seeing problems caused by this. For now these are just warnings you can ignore if you don't understand Perl. In any case better use the original Perl which came with your system for any scripts which are shipped with the system. If you understand Perl you can fix the warning by escaping the `{` inside the Regex, i.e. `\{`. – Steffen Ullrich Apr 02 '17 at 07:16
  • Thanks a lot! That worked. Yeah I did a sudo apt-get upgrade and somehow newer packages got installed on my Ubuntu 14.04. Am slowly trying to fix them one by one... T_T Does this by any chance affect my samba or ldap? – TheCabDriverCheatedMeToday Apr 02 '17 at 07:29
  • Since it is unknown what exactly the changes were it is unknown what impact they might have. – Steffen Ullrich Apr 02 '17 at 08:31

2 Answers2

16

It's a deprecation warning indicating the code will stop working in the future.

If you want to match a { literally, you should escape it.

In other words, you can fix the issue (silencing the warning) by replacing the first { with \{.

ikegami
  • 367,544
  • 15
  • 269
  • 518
-2

Instead of escaping the left or right brace, how about using its unicode equivalent value? Like so:

while ($rest =~ m/^(.*?)(\\)?\$\x7B([^\x7B\x7D]+)\x7D(.*)$/sg) {

I had the similar problem, and this solved it for me.

Jacques
  • 991
  • 1
  • 12
  • 15