1CLASS(3) User Contributed Perl Documentation CLASS(3)
2
3
4
6 CLASS - Alias for __PACKAGE__
7
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
21 CLASS and $CLASS are both synonyms for __PACKAGE__. Easier to type.
22
23 $CLASS has the additional benefit of working in strings.
24
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
31 From February 2022 onward: Jacques Deguest <jack@deguest.jp>
32
33 Michael G Schwern <schwern@pobox.com>
34
36 This program is free software; you can redistribute it and/or modify it
37 under the same terms as Perl itself.
38
39 See <http://www.perl.com/perl/misc/Artistic.html>
40
42 perlmod(1)
43
44
45
46perl v5.36.0 2022-07-22 CLASS(3)