Perl Moose attribute not force type checking [closed]

The problem is the new defined at line 64 of Cat.pm. Moose provides a new method, so you don’t need to write your own. Remove that new method, and it works fine.

The other bit that should have triggered a “aha!” is the

use 5.006;
use strict;
use warnings;

which is present halfway down your Cat.pm code.

If you’re going to use POD documentation, you should either embed your code within the docs (allowing the docs to enhance your inline comments); or you should put all your code up top and make a clear POD at the bottom. Either way, consistency will help avoid these kinds of problems in the future.

Leave a Comment