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 $^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 😭

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