Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Perl Modules with 2 or more classes

by Anonymous Monk
on Oct 19, 2011 at 10:42 UTC ( #932353=note: print w/replies, xml ) Need Help??


in reply to Perl Modules with 2 or more classes

Yes. See Simple Module Tutorial, package
package Foo; use Any::Moose; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); no Any::Moose; package Bar; use Any::Moose; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); has 'z' => (is => 'rw', isa => 'Int'); no Any::Moose;

Replies are listed 'Best First'.
Re^2: Perl Modules with 2 or more classes
by zwon (Abbot) on Oct 19, 2011 at 14:30 UTC

    Or you can create classes dynamically with Class::MOP::Class and Moose::Meta::Class

    use 5.012; use warnings; use Class::MOP; for (qw(foo bar baz)) { my $class = ucfirst($_); Class::MOP::Class->create( $class => ( methods => { $_ => sub { say $class } } ) ); } Foo->foo; Bar->bar; Baz->baz;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932353]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2016-12-05 13:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (82 votes). Check out past polls.