Sub::Name(3)

πŸ’– NAME β€” Sub::Name πŸ’–

okay so bestie, this is Sub::Name β€” yes, a User Contributed Perl Documentation page, we love a community era β€” and the actual name section is literally: Sub::Name - (Re)name a sub. slay.


✨ VERSION ✨

version 0.28. tiny but mighty, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

use Sub::Name;

subname $name, $subref;

$subref = subname foo => sub { ... };

🌸 DESCRIPTION 🌸

okay so this module has only one function, which is also exported by default, periodt:

πŸŽ€ subname NAME, CODEREF πŸŽ€

subname assigns a new name to the referenced sub. If the package specification is omitted in the name, then the current package is used. The return value is the sub β€” that's it, that's the whole return situation.

⚠️ important vibe check: the name is only used for informative routines (caller, Carp, etc). You won't be able to actually invoke the sub by the given name. To allow that, you need to do glob-assignment yourself. no cap.

Note that for anonymous closures (subs that reference lexicals declared outside the sub itself) you can name each instance of the closure differently, which can be very useful for debugging. literally iconic for debugging, bestie.


πŸ‘€ SEE ALSO πŸ‘€

  • Sub::Identify β€” for getting information about subs.
  • Sub::Util β€” set_subname is another implementation of "subname". iykyk

🫢 SUPPORT 🫢

Bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Sub-Name> (or bug-Sub-Name@rt.cpan.org <mailto:bug-Sub-Name@rt.cpan.org>).

There is also an irc channel available for users of this distribution, at #toolchain on irc.perl.org <irc://irc.perl.org/#toolchain>.


🌟 AUTHOR 🌟

Matthijs van Duin <xmath@cpan.org>.


πŸ’œ CONTRIBUTORS πŸ’œ

  • Karen Etheridge <ether@cpan.org>
  • Graham Knop <haarg@haarg.org>
  • Leon Timmermans <fawaka@gmail.com>
  • Florian Ragwitz <rafl@debian.org>
  • Reini Urban <rurban@cpan.org>
  • Matthijs van Duin <xmath-no-spam@nospam.cpan.org>
  • Dagfinn Ilmari MannsΓ₯ker <ilmari@ilmari.org>
  • gfx <gfuji@cpan.org>
  • Aristotle Pagaltzis <pagaltzis@gmx.de>
  • Alexander Bluhm <alexander.bluhm@gmx.net>
  • J.R. Mash <jmash.code@gmail.com>

This software is copyright (c) 2004, 2008 by Matthijs van Duin, all rights reserved; copyright (c) 2014 cPanel Inc., all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

mwah πŸ’‹ β€” this page is from perl v5.42.0, dated 2024-12-16, and it's Sub::Name(3), bestie. πŸ’–

πŸ“¦ where this page comes from