new tasks

This commit is contained in:
Ingy döt Net 2013-04-09 00:46:50 -07:00
parent 2a4d27cea0
commit 80737d5a6a
1194 changed files with 15353 additions and 1 deletions

View file

@ -0,0 +1,12 @@
{
package MyClass;
use Moose;
has 'variable' => (is => 'rw', default => 0);
# constructor and accessor methods are added automatically
sub some_method {
my $self = shift;
$self->variable(1);
}
}

View file

@ -0,0 +1,7 @@
use MooseX::Declare;
class MyClass {
has 'variable' => (is => 'rw', default => 0);
method some_method {
$self->variable(1);
}
}

View file

@ -0,0 +1,4 @@
my $instance = MyClass->new; # invoke constructor method
$instance->some_method; # invoke method on object instance
# instance deallocates when the last reference falls out of scope

View file

@ -0,0 +1,19 @@
{
# a class is a package (i.e. a namespace) with methods in it
package MyClass;
# a constructor is a function that returns a blessed reference
sub new {
my $class = shift;
bless {variable => 0}, $class;
# the instance object is a hashref in disguise.
# (it can be a ref to anything.)
}
# an instance method is a function that takes an object as first argument.
# the -> invocation syntax takes care of that nicely, see Usage paragraph below.
sub some_method {
my $self = shift;
$self->{variable} = 1;
}
}