June 2026 Archives

Introducing constant::string and constant::string::uc

If you're like me, you use a constant a lot (I may overuse it). I often use it to turn typos in words and fields into compile-time errors, and for that I usually create constants that either are the named the same as the word, or the word uppercased, like this

use constant +{ SERVICE => 'Service', INSTANCE => 'Instance' };

or

use constant +{ map +( $_ => $_ ), @constants }

and doing that too many times inspired the creation of constant::string and constant::string::uc.

About James

user-pic I blog about Perl.