Before v5.30, a positive lookbehind with indeterminate, "variable width" pattern fails to compile with the Variable length lookbehind not implemented
error.
In v5.30, you are allowed to use a lookbehind pattern that can match up to 255 chars.
Using a lookbehind assertion (like (?<=foo?)
or (?<!ba{1,9}r)
previously would generate an error and refuse to compile. Now it
compiles (if the maximum lookbehind is at most 255 characters), but
raises a warning in the new experimental::vlb
warnings category. This
is to caution you that the precise behavior is subject to change based
on feedback from use in the field.
If you use (?<=WORD\s+)
, you will get a Lookbehind longer than 255 not implemented
error since the regex engine needs to know in advance that the length of the subpattern won't be longer than 255 and the +
quantifier has an indeterminate length. So, (?<=WORD\s{0,255})
would work.
In your case, you know your lookbehind pattern will never match more than 255 chars, so just turn that experimental warning like any other experimental warnings:
no warnings qw(experimental::vlb);
Note: Make sure that the above line is placed after the use warnings;
line, if present, or it will have no lasting effect, being overridden by use warnings;
.