1CLASS(3)              User Contributed Perl Documentation             CLASS(3)
2
3
4

NAME

6       CLASS - Alias for __PACKAGE__
7

SYNOPSIS

9         package Foo;
10         use CLASS;
11
12         print CLASS;                  # Foo
13         print "My class is $CLASS\n"; # My class is Foo
14
15         sub bar { 23 }
16
17         print CLASS->bar;     # 23
18         print $CLASS->bar;    # 23
19

DESCRIPTION

21       CLASS and $CLASS are both synonyms for __PACKAGE__.  Easier to type.
22
23       $CLASS has the additional benefit of working in strings.
24

NOTES

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

AUTHOR

31       Michael G Schwern <schwern@pobox.com>
32

LICENSE

34       This program is free software; you can redistribute it and/or modify it
35       under the same terms as Perl itself.
36
37       See <http://www.perl.com/perl/misc/Artistic.html>
38

SEE ALSO

40       perlmod(1)
41
42
43
44perl v5.34.0                      2022-01-20                          CLASS(3)
Impressum