CLASS(3)

πŸŽ€ CLASS(3) πŸŽ€

okay bestie, welcome to the User Contributed Perl Documentation page for CLASS(3) β€” it’s giving tiny module, huge convenience. we’re gonna get you comfy with it, fr fr. πŸ’…βœ¨

✨ NAME ✨

CLASS β€” Alias for __PACKAGE__

🌸 SYNOPSIS 🌸

  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

πŸ’– DESCRIPTION πŸ’–

okay so CLASS and $CLASS are both literally synonyms for __PACKAGE__. They’re just easier to type β€” that’s the whole slay. 🫢

$CLASS also has the extra benefit of working inside strings β€” iconic behavior, no cap. πŸŽ€

🧚 NOTES 🧚

  • 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.) πŸ’œ

πŸ‘‘ AUTHOR πŸ‘‘

  • From February 2022 onward: Jacques Deguest <jack@deguest.jp>
  • Michael G Schwern <schwern@pobox.com>

πŸ’œ LICENSE πŸ’œ

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>

🌈 SEE ALSO 🌈

perlmod(1)


kisses bestie πŸ’‹ this page is from perl v5.42.0, dated 2023-09-24, and yeah it’s CLASS(3) β€” go be iconic with your package names 🫢✨

πŸ“¦ where this page comes from