Perl 脚本停止。错误:找不到 unicode 属性定义 ASCII



我继承了一些perl脚本。(我不是perl程序员)。

我在下面的上看到一个错误"can't find unicode property definition ascii"

$value =~ s/[^[:p{ascii}]]//g 

这个错误会导致程序停止执行吗?因为这是程序停止前打印的最后一行。

在它放弃之前,同一条线路已经运行了1000多次。问题出在哪里?

我倾向于$value的值不是导致问题的原因我说得对吗

在我看来,{ascii}似乎已从unicode定义中删除。这能做到吗?还是我完全搞错了

在我看来,ascii必须是大写的ASCII

$value =~ s/[^p{ASCII}]//g 

用\p{ascii}测试:

#> cat test.pl
#!/usr/bin/perl
my $str = q/☺ùùabvcedhkè ég"/;
$str =~ s/[^p{ascii}]//g;
print $str,"n";
#> perl test.pl
Can't find Unicode property definition "ascii" at test.pl line 3.

使用\p{ASCII}进行测试:

cat test.pl
#!/usr/bin/perl
my $str = q/☺ùùabvcedhkè ég"/;
$str =~ s/[^p{ASCII}]//g;
print $str,"n";
#> perl test.pl
abvcedhk g"

相关内容

最新更新