Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moose && utf8 (package|method) names

Tags:

utf-8

perl

moose

Having this:

use utf8;
package ÁngryBird;   #note the Á in the package name

perl -c result is syntax OK.

use utf8;
package ÁngryMoose;
use Moose;

perl -c says,

ÁngryMoose is not a module name at 
/opt/local/lib/perl5/site_perl/5.12.4/darwin-multi-2level/Class/MOP/Package.pm
 line 209.

So, what's wrong in the code?

like image 271
cajwine Avatar asked Jan 17 '23 07:01

cajwine


1 Answers

Moose uses this regexp from Package::Stash::PP for checking package name:

elsif ($package !~ /\A[0-9A-Z_a-z]+(?:::[0-9A-Z_a-z]+)*\z/) {
    confess "$package is not a module name";
}

or this regexp from Package::Stash::XS:

const char *vmre = "\\A[0-9A-Z_a-z]+(?:::[0-9A-Z_a-z]+)*\\z";

But you may create your own package stash inplementation in namespace Package::Stash, and use it by setting environment variable PACKAGE_STASH_IMPLEMENTATION or variable $Package::Stash::IMPLEMENTATION before loading Package::Stash. For example, if your implementation have name Package::Stash::My then set variable to My.

like image 108
Denis Ibaev Avatar answered Jan 23 '23 21:01

Denis Ibaev