The package { ... }
syntax you're trying to use was added in perl 5.14.0 (released in May 2011).
If you want to run on perl 5.12 and older, change your code to look like:
{
package Cat;
use Moose;
has 'name' => (...);
# etc.
}
my $test_obj = Cat->new(...);
# etc.
The package
declaration won't leak outside of the braces, so the code at the bottom will be running in package main
, and my
or our
variables will stay inside of the block as well.