- or download this
package My::UNIVERSAL;
use base qw(Class::Data::Inheritable);
1;
- or download this
package My::UNIVERSAL;
use strict;
...
);
1;
- or download this
package Creature;
use base 'My::UNIVERSAL';
...
name => 'Alice',
gender => 'female',
} );
- or download this
$VAR1 = bless( {
gender => 'female',
name => 'Alice'
}, 'Creature' );
- or download this
sub mk_accessors {
my ( $class, @accessors ) = @_;
foreach my $accessor (@accessors) {
...
};
}
}
- or download this
sub area {
my $self = shift;
return $self->height * $self->width;
}
- or download this
use Scalar::Util 'reftype';
sub new {
...
}
return $self;
}
- or download this
$VAR1 = bless( {
'Creature::gender' => 'female',
'Creature::name' => 'Alice'
}, 'Creature' );
- or download this
$creature->name('Bob')
->gender('unknown');
- or download this
my $creature = Creature->new( {
name => 'Alice',
gender => 'female',
foo => 1,
} );
- or download this
__PACKAGE__->mk_class_data('__data_key');
sub new {
...
return unless exists $self->{ $self->__data_key }->{$attribute};
goto $check_attribute;
}
- or download this
package Creature;
use base 'My::UNIVERSAL';
...
$self->_must_have('name');
$self->_may_have('gender');
}
- or download this
package IP::Address;
use base 'My::Universal';
...
my $ip = IP::Address->new({ ip => $some_ip });
print $ip->address; # prints $some_ip
- or download this
my $check_keys = sub {
my $self = shift;
my $data = delete $self->{ $self->__data_key };
...
$self->$check_keys;
return $self;
}
- or download this
my $creature = Creature->new( {
name => 'Alice',
gender => 'female',
...
} );
# Unknown keys to constructor: (bar, foo)
- or download this
package Tall::Square;
use Scalar::Util 'looks_like_number';
...
}
1;
- or download this
package My::UNIVERSAL;
use strict;
...
}
1;