Class::Methods - Object methods for working with classes
use Class::Methods; my $container = bless [], Class::Methods->new( count => sub { return scalar @{$_[0]} }, ); print $container->count; # prints 0 $container->extend( push => sub { push @{$_[0]}, $_[1..$#_] } ); $container->push( qw[apples oranges] ); $container->remove( "push" ); print $container->count; # prints 2 # XXX: $container->base('ARRAY'); # import push(), pop(), splice(), etc.
After discussing Ruby with Simon, I wrote this module to implement OO in Perl via the builtin inheritance-based method system.
It seems to be pretty fun to work with. Kind of resesmbles ruby, though, and I suspect it might start enroaching on Perl 6.
This is the first release, to share the madness with y'all. I've planned serious uses of this module, so perhaps it'll find a good home.
test.pl is the only code example right. The core's small, and fun to read.
Richard Soderberg, rsod@cpan.org
Class::Object
To install Class::Methods, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Methods
CPAN shell
perl -MCPAN -e shell install Class::Methods
For more information on module installation, please visit the detailed CPAN module installation guide.