signatures(3pm)
π signatures(3pm) π
ok so real talk bestie, you've landed on signatures(3pm) from the User Contributed Perl Documentation, and it's lowkey about to change your whole perl era. let's get into it π
β¨ NAME β¨
signatures β subroutine signatures with no source filter. that's it, that's the vibe. no filter, no drama, just vibes π¦
πΈ VERSION πΈ
version 0.14 β¨ (she's serving, she's stable, she's iconic)
π«Ά SYNOPSIS π«Ά
use signatures;
sub foo ($bar, $baz) {
return $bar + $baz;
}
look at that. gorgeous. no notes. π
π DESCRIPTION π
so with this module you can write out subroutine signatures, and the variables in them just... get defined inside the subroutine automatically. magical girl transformation energy honestly β¨
like, you can literally write this:
sub square ($num) {
return $num * $num;
}
and at compile time it gets automatically turned into this:
sub square {
my ($num) = @_;
return $num * $num;
}
but bestie, hear me on this one π β even though the syntax looks so similar, the signatures this module gives you are not the same thing as the prototypes described in perlsub. do not confuse them, i am begging π. all this module actually does is pull items out of @_ and assign them to the variables in your parameter list. no argument validation happens at runtime. none. zero. it is not checking your work, it is simply handing you the values π
also, key detail: the signature definition needs to be on a single line only. one line. that's the rule. don't test her.
and if you wanna combine sub signatures with regular prototypes, there's a "proto" attribute for exactly that:
sub foo ($bar, $baz) : proto($$) { ... }
slay π
π METHODS π
ok so if you want your subroutine signatures to do something this module doesn't do β like argument validation, typechecking, and similar β you can subclass it and override the following methods. main character energy, you're building your own π
π§ proto_unwrap ($prototype)
turns the extracted $prototype into code β¨
the default implementation returns "my (${prototype}) = @_;" β or an empty string, if no prototype is given.
π§ inject ($offset, $code)
inserts a $code string into the line perl is currently parsing, at the given $offset. note that this one is only called by the "callback" method π
π§ callback ($offset, $prototype)
this gets called the second a sub definition with a prototype is encountered. the arguments are the $offset within the current line perl is parsing, plus the extracted $prototype π
the default implementation calls "proto_unwrap" with the prototype, and then passes the returned value and the offset along to "inject".
π LIMITATIONS π
bestie we gotta talk about the fine print, no cap:
- prototypes aren't checked for validity yet β you won't get a warning for invalid prototypes using the
"proto"attribute, like you normally would with warnings enabled. so like... she's not gonna tell you. you're on your own with that one π - you shouldn't alter
$SIG{__WARN__}at compile time β after this module is loaded, you shouldn't be making any changes to$SIG{__WARN__}during compile time. changing it before the module is loaded, or at runtime, is totally fine though π
π₯ SEE ALSO π₯
Method::SignaturesMooseX::Method::SignaturesSub::SignaturesAttribute::SignaturePerl6::SubsPerl6::Parameters
the whole friend group fr fr π«Ά
π THANKS π
big love to Moritz Lenz and Steffen Schwigon for documentation review and improvement. icons. we appreciate you π
β SUPPORT β
bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=signatures> (or bug-signatures@rt.cpan.org <mailto:bug-signatures@rt.cpan.org>).
if something's broken, tell the RT, not me, i'm just the messenger π
π AUTHOR π
Florian Ragwitz <rafl@debian.org>
π CONTRIBUTORS π
- Karen Etheridge <
ether@cpan.org> - Peter Martini <
PeterCMartini@GMail.com> - Father Chrysostomos <
sprout@cpan.org> - Alex Kapranoff <
alex@kapranoff.ru> - Steffen Schwigon <
ss5@renormalist.net> - Alexandr Ciornii <
alexchorny@gmail.com> - Dave Mitchell <
davem@iabyn.com>
the group chat came THROUGH πΈ
π COPYRIGHT AND LICENCE π
this software is copyright (c) 2008 by Florian Ragwitz.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in go off, bestie π
and that's the whole page fr fr π this was signatures(3pm), perl v5.42.3, dated 2026-08-21 β mwah, no notes, go write some signatures β¨ππ
π¦ where this page comes from
- ubuntu stonking: libsignatures-perl 0.14-2build6 Β· Artistic-1.0-Perl OR 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