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.


In reply to Re: Parse::RecDescent and unicode by ikegami
in thread Parse::RecDescent and unicode by cruftectomy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.