constant::tiny(3)

πŸ“¦
version 1.02 Β· 2 versions
, in fedora 43

πŸ’– constant::tiny β€” the manual page, but make it a group chat πŸ’–

okay bestie, so we're talking about constant::tiny(3) β€” it lives in the User Contributed Perl Documentation section, and honestly? she's small, she's efficient, she's giving minimalist queen. πŸŽ€


✨ NAME ✨

constant::tiny β€” a Perl pragma to declare constants. that's it. that's the whole job. πŸ’…


🌸 SYNOPSIS 🌸

look at this. literally so clean:

use constant::tiny;
use constant PI    => 4 * atan2(1, 1);
use constant DEBUG => 0;

print "Pi equals ", PI, "...\n" if DEBUG;

that's the whole vibe. you add one little line, you get constants. iconic. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so constant::tiny is a lightweight version of the Perl standard module constant.pm. like, the same energy but smaller and leaner. here are the key differences:

  • it only works on Perl 5.10+, because that lets it simplify a good chunk of the code. no cap. 🧚
  • it does NOT support Unicode names. if you need to create constants with Unicode names, please go use the standard constant.pm module instead. she's not built for that and she knows it. πŸ™ˆ
  • it's stricter about valid names: it only allows names with alphanums ([a-zA-Z0-9]) and underscore (_), and it allows one optional leading underscore. so yes, picky. but in a cute way.

to make life easy, constant:tiny uses the normal constant API. the main advantage? switching your code over to constant::tiny means simply adding it before the first use constant. that's it. one line. slay.

the disadvantage is that, obviously, both modules can't be used at the same time. if the normal constant was loaded before constant::tiny, then constant::tiny just… won't do anything? it steps aside and lets the normal constant do the work. very demure, very mindful. 🫢

other than that, the usage is (nearly) exactly the same as with the standard constant module. for more details, please read constant.


πŸ’œ Rationale πŸ’œ

the origin story, bestie. the reason this module got written was that starting with version 1.24, constant always loaded utf8_heavy.pl, which eats up some memory. usually that's not a problem at all! but in some particular cases β€” embedded Perl, or programs that fork a lot Γ  la CGI β€” the increased memory cost can become a genuine concern. 😭

so this module was written as an alternative solution, with no support for Unicode names, so that programs working in memory-constrained environments could have better control. practical queen behavior. πŸ’…

and here's the funny part β€” the day constant::tiny was released on CPAN (the code had actually been written two months earlier as a proof of concept), Brad Gilbert proposed a patch for constant to delay loading utf8_heavy.pl until it was actually necessary. πŸ’€

which means constant::tiny is less useful now β€” which is good news, actually! β€” but it can still address specific needs, if you want to restrict constant names to alphanums only. still got a job. still employed. periodt. ⭐


πŸŽ€ SUPPORT πŸŽ€

you can find documentation for this module with the perldoc command:

perldoc constant::tiny

you can also look for information at:


😭 BUGS 😭

please report any bugs or feature requests to contant-tiny at rt.cpan.org, or through the web interface at <https://rt.cpan.org/Public/Dist/Display.html?Name=constant-tiny>.

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. so you're not screaming into the void, bestie. someone is reading it. 🫢

🌸 ACKNOWLEDGEMENTS 🌸

this module is heavily based on constant.pm, which was originally written by Tom Phoenix, Casey West, Nicholas Clark, Zefram and many other folks from the Perl 5 Porters. legends, all of them. πŸ‘‘


πŸ’… AUTHOR πŸ’…

SΓ©bastien Aperghis-Tramoni <sebastien at aperghis.net>


🌈 LICENSE 🌈

this module is free software; you can redistribute it or modify it under the same terms as Perl itself. go wild. responsibly. πŸ’–


and that's the whole page, bestie!! πŸŽ€ this doc shipped as part of perl v5.42.0, dated 2025-07-25, and it's filed under constant::tiny(3). go forth and declare your constants. slay. βœ¨πŸ¦‹

πŸ“¦ where this page comes from