Perl script stops. Error: Can't find unicode property definition ASCII

1.2k views Asked by At

I've inherited some perl scripts. (I'm not a perl programmer).

I'm seeing an error "can't find unicode property definition ascii" on the below line

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

Would this error cause the program execution to stop? As it's the last line printed before the program halts.

That same line has been run over 1,000 times before, before it gives up. What can the problem be?

I leaning towards that the value of $value is NOT what is causing the problem. Am I right?

It seems to me as though {ascii} has been removed from unicode definitions. Can this be done or am I completely barking up the wrong tree?

1

There are 1 answers

6
Toto On

It seems to me that ascii must be uppercase ASCII

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

test with \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.

test with \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"