http://www.perlmonks.org?node_id=816410

bv has asked for the wisdom of the Perl Monks concerning the following question:

Hoping someone can straighten me out. I'm trying to do this the right way, so if there's a better way, I'd love to hear it.

I wrote a Model for my Catalyst app that just loads a YAML file and provides accessors and validation. I copied some code from Catalyst::Model::DBI, specifically the code for new, but I'm getting warnings about my use of NEXT.

package Clio::Model::YAML; use namespace::autoclean; use base 'Catalyst::Model'; use MRO::Compat; use Data::Dumper; use YAML::Any qw(LoadFile); use warnings; use strict; __PACKAGE__->mk_accessors('defs'); sub new { my $class = shift; my $self = $class->NEXT::new(@_); $self->{defs} = mergekeys( LoadFile "db/clio.yml" ); return $self; }

The error I get is this:

$ ./script/clio_test.pl Clio::Model::YAML uses NEXT, which is deprecated. Please see the Class +::C3::Adopt::NEXT documentation for details. NEXT used at /home/mill +er/actions/note_taker/Clio/script/../lib/Clio/Model/YAML.pm line 16

I read the documentation, and tried to follow it (hence the use MRO::Compat above). It says,

You add use MRO::Compat to the top of a package as you start converting it, and gradually replace your calls to NEXT::method() with maybe::next::method(), and calls to NEXT::ACTUAL::method() with next::method().

but when I change my code to my $self = $class->maybe::next::new(@_); I get this error:

Couldn't load class (Clio) because: Couldn't instantiate component "Clio::Model::YAML", "Can't locate object method "new" via package "maybe::next" at /home/miller/actions/note_taker/Clio/script/../lib/Clio/Model/YAML.pm line 16."Compilation failed in require at /usr/local/lib/perl/5.10.1/Class/MOP.pm line 98.

Am I reading this wrong? How am I supposed to do this under C3? Thanks for any help you can give.

UPDATE: Solved the problem. Short version: should be literally $class->maybe::next::method(@_). See my response below for details.


print map{substr'hark, suPerJacent other l',$_,1}(11,7,6,16,5,1,15,18..23,8..10,24,17,0,12,13,3,14,2,4);