Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

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;
}
}

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