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 $^H hints variable, the use vars and use subs declarations 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 with no vars or no 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