Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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;


Comment on Re: Perl Modules with 2 or more classes
Download Code
Re^2: Perl Modules with 2 or more classes
by zwon (Monsignor) 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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-07-24 09:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (159 votes), past polls