Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • by hdp (1658) on 2009.03.18 23:15 (#67861) Journal

    Moving along, were I to eliminate base classes, that would also eliminate this silliness:

            sub foo {
                    my $proto = shift;
                    my $class = ref $proto || $proto;
                    die "You must override 'foo' in $class";

    That fires at runtime, not compile time. Just adding a requires qw'foo'; to your role and this becomes a compile-time failure.

    Alternately, if the "foo" you're overriding there is (as it so often is) something like this:

    sub foo_plugins {
        return ("My::Foo", "External::Library::Foo");

    MooseX::Role::Parameterized [] might be a good option. e.g.

    use MyRole => { foo_plugins => ["My::Foo", "External::Library::Foo" ] };

    # elsewhere...
    package MyRole;
    use MooseX::Role::Parameterized;
    parameter foo_plugins => (
        isa => 'ArrayRef[ClassName]',
        required => 1,
    role {
        my $p = shift;
        method munge_stuff => sub {
            # do something for each @{$p->foo_plugins}