subs(3perl)
π subs β the Perl pragma that predeclares subroutine names π
okay bestie, welcome to subs (that's subs(3perl) for the formal girlies) β part of the Perl Programmers Reference Guide. it's short, it's sweet, and it's here to let you call your subroutines before they even exist. main character energy fr fr. β¨
β¨ SYNOPSIS β¨
use subs qw(frob);
frob 3..10;
like. that's it. that's the whole vibe. π
πΈ DESCRIPTION πΈ
so what's it doing? it predeclares every subroutine whose name you put in that list β which means you get to use them without parentheses, as list operators, even before they're actually declared. yes girl, calling subs that don't exist yet. iconic behavior honestly. π
β οΈ okay now the important part, don't scroll past this: Unlike pragmas that mess with 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. the whole thing. the entire kingdom. π And nope β you cannot rescind these declarations withno varsorno subs. once it's declared, it's declared. no take-backs, no undo button, no "oops I changed my mind" π«Ά
want the deeper lore? go read "Pragmatic Modules" in perlmodlib and "strict subs" in strict. that's where the real ones hang out. π
and that's the tea, bestie β go forth and predeclare responsibly π
this lil page came from perl v5.44.0, dated 2026-10-17, and it lives at subs(3perl). mwah. ππΈ
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms