slots - A simple pragma for managing class slots.
version 1.05
package Point { use strict; use warnings; use parent 'UNIVERSAL::Object'; use slots ( x => sub { 0 }, y => sub { 0 }, ); sub clear { my ($self) = @_; $self->{x} = 0; $self->{y} = 0; } } package Point3D { use strict; use warnings; use parent 'Point'; use slots ( z => sub { 0 }, ); sub clear { my ($self) = @_; $self->next::method; $self->{z} = 0; } }
This is a very simple pragma which takes a set of key/value arguments and assigns it to the %HAS package variable of the calling class.
%HAS
This module will also detect superclasses and insure that slots are inherited correctly, this wil occur during the next available UNITCHECK phase.
Stevan Little <stevan@cpan.org>
This software is copyright (c) 2017, 2018 by Stevan Little.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install slots, copy and paste the appropriate command in to your terminal.
cpanm
cpanm slots
CPAN shell
perl -MCPAN -e shell install slots
For more information on module installation, please visit the detailed CPAN module installation guide.