in reply to Parse::RecDescent and unicode
Parse::RecDescent produces a string containing Perl code which is evaled in a different package (namespace). You need to use charnames in that package:
use strict; use warnings; use Parse::RecDescent (); #$::RD_TRACE = 1; $::RD_HINT = 1; my $parser = new Parse::RecDescent(<<'EOG') || die; { # Put pragmas, modules and functions # used by the parser in these curlies. use strict; use warnings; use charnames ':full'; } ex1: "\N{DIAMOND OPERATOR}" ex2: "\x{22c4}" ex3: /\p{Letter}/ EOG my $text = chr(0x22C4); print("$_: ", $parser->$_($text) ? "match" : "no match", "\n") foreach qw( ex1 ex2 ex3 ); __END__ output ====== ex1: match ex2: match ex3: no match
Note: \p{Letter} didn't work for me when using ActivePerl 5.6.1 -- Can't find unicode character property definition via main->Letter or Letter.pl. -- but it worked (as shown above) when using ActivePerl 5.8.0.
|
|---|