Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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?
marioroy just logged in to say that MCE::Hobo has passed testing and therefore will continue to run like threads but have managed capabilities similar to Parallel:: ForkManager. It allows multiple managed instances to run simultaneously. Zero limitations.
marioroy it's taken a long time to make this possible.
marioroy will post demonstrations after release

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2017-07-28 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (433 votes). Check out past polls.