YAPE::Regex::Explain не работает с использованием 5.014;
Этот код:
use strict;
use warnings;
use YAPE::Regex::Explain;
print YAPE::Regex::Explain->new( qr/d+/ )->explain();
печать
The regular expression:
(?-imsx:d+)
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
d+ 'd' (1 or more times (matching the most
amount possible))
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
но этот код
use 5.014; #added this
use strict;
use warnings;
use YAPE::Regex::Explain;
print YAPE::Regex::Explain->new( qr/d+/ )->explain();
только для печати:
The regular expression:
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
В чем дело?
1 ответ
Решение
Особенность unicode_strings
изменяет, какой шаблон создается.
$ perl -le'no feature qw( unicode_strings ); print qr/\d+/'
(?^:\d+)
$ perl -le'use feature qw( unicode_strings ); print qr/\d+/'
(?^u:\d+)
YAPE:: Regex:: Explain не может справиться со многими новыми (и не очень новыми) функциями из-за отсутствия обслуживания. Это задокументировано в разделе ОГРАНИЧЕНИЯ.
Бьюсь об заклад, он получает флаги, используя re::regexp_pattern
(объясняя, почему это отображает (?-imsx:d+)
вместо (?^:\d+)
) и подавится "u
флаг, о котором он не знает.
$ perl -le'no feature qw( unicode_strings ); print +(re::regexp_pattern(qr/\d+/))[1]'
$ perl -le'use feature qw( unicode_strings ); print +(re::regexp_pattern(qr/\d+/))[1]'
u