The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Class - A Generic Object Class to Inherit From

SYNOPSIS

    use parent qw( Class );
    
    sub init
    {
        my $self = shift( @_ );
        return( $self->SUPER::init( @_ ) );
    }

Support for legacy code:

    package Foo;
    use CLASS;

    print CLASS;                  # Foo
    print "My class is $CLASS\n"; # My class is Foo

    sub bar { 23 }

    print CLASS->bar;     # 23
    print $CLASS->bar;    # 23

VERSION

    v1.1.5

DESCRIPTION

This package inherits all its features from Module::Generic and provides a generic framework of methods to inherit from and speed up development.

It also provides support for legacy code whereby CLASS and $CLASS are both synonyms for __PACKAGE__. Easier to type.

$CLASS has the additional benefit of working in strings.

Class is a constant, not a subroutine call. $CLASS is a plain variable, it is not tied. There is no performance loss for using Class over __PACKAGE__ except the loading of the module. (Thanks Juerd)

SEE ALSO

Class::Stack, Class::String, Class::Number, Class::Boolean, Class::Assoc, Class::File, Class::DateTime, Class::Exception, Class::Finfo, Class::NullChain

AUTHOR

From February 2022 onward: Jacques Deguest <jack@deguest.jp>

Michael G Schwern <schwern@pobox.com>

COPYRIGHT & LICENSE

Copyright (c) 2021 DEGUEST Pte. Ltd.

You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.