Custom character class in Perl 5.018

I have a parsing environment (Marpa :: R2 :: Scanless) that needs to use separate Perl regex character classes to control tokenization. I have something to symbolize, which does not seem to match any of the existing character classes. So, after searching the perlunicode docs, I came up with the following code, except that it does not work properly. I expect to see a series of dots interspersed with all non-alphanumeric (except for parens). Instead, I get a runtime error due to the inability to find a character class.

#!/usr/bin/env perl use 5.018; use utf8; local $| = 1; for my $i (map { chr($_) } 32 .. 127) { if ($i =~ /\p{Magic::Wow}/) { print $i; } else { print "."; } } package Magic; sub Wow { return <<'MAGIC'; +utf8::Assigned -utf8::Letter -utf8::Number -0028 -0029 MAGIC } 1; 

Any hints, tips, tricks, or suggestions?

+7
regex perl unicode
source share
1 answer

Name sub IsWow and the property Magic::IsWow .

Quote Custom character properties in perlunicode :

You can define your own binary character properties by defining routines whose names begin with "B" or "I".

+7
source share

All Articles