I have some code which looks (roughly) like this:

    foreach my $thing (@things) {
        my $package = get_package($thing);
        eval <<"    END";
        package $package;
        use Moose;
        extends 'Some::Base::Class';
        with 'Does::Something';
        END
        confess $@ if $@;
        $package->meta->make_immutable;
        $package->setup($thing);
    }

I would very much like to refactor this to not use that nasty eval.  If I don't 
know a package's name until runtime, how can I tell it to "use Moose" with the 
appropriate inheritance and roles?

 
Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to