subs(3pm)
β¨ NAME β¨
okay so bestie, this page is subs β it's a Perl pragma π
and its whole job is to predeclare subroutine names for you. That's it, that's the gig. It's subs(3pm), from the Perl Programmers Reference Guide, iykyk π«Ά
πΈ SYNOPSIS πΈ
use subs qw(frob);
frob 3..10;
like, look at that. frob gets called like a little list operator before it's even been formally introduced. iconic behavior honestly π
π¦ DESCRIPTION π¦
So here's the vibe: this predeclares all the subroutines whose names are in the list π which means you get to use them without parentheses β as list operators, no cap β even before they're declared. yes, before. main character energy β¨
β οΈ now listen, this part matters: unlike pragmas that affect the$^Hhints variable, theuse varsanduse subsdeclarations are not lexically scoped to the block they appear in. they affect the entire package they show up in π
and because of that, it is not possible to rescind these declarations with no vars or no subs. nope. no takebacks. once it's in the package, it's in the package π periodt.
also worth a peek, fr fr:
- the "Pragmatic Modules" section over in
perlmodlibπ - the "strict subs" section over in
strictπ
okay that's the whole page, short and sweet, ate and left no crumbs π
mwah π β brought to you by perl v5.42.3, dated 2026-11-03, and this little subs(3pm) moment ππ§π
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms