Function::ID - Variables to let functions know their names.
This documentation describes version 0.02 of Function::ID, March 29, 2003.
use Function::ID; sub your_routine { print "Hi, I'm $this_function, or $this_fn for short!\n"; }
Output:
Hi, I'm main::your_routine, or your_routine for short!
This module provides two tied variables, $this_function and $this_fn, which when invoked contain the name of the function they're being used in. In other words, they return the identity of the function that uses them. This can be useful for log, error, or debug messages.
$this_function
$this_fn
Both these variables contain undef in the main portion of a program's code (ie, outside of any function body).
undef
$this_function returns the fully-qualified name of the current function, including its package. For example: 'Foo::Bar::Baz::my_function'.
'Foo::Bar::Baz::my_function'
$this_fn returns the name of the current function, with no package name. For example: 'my_function'.
'my_function'
This module exports the following symbols into the caller's namespace:
$this_function $this_fn
Carp.pm (included with Perl)
Eric J. Roode, roode@cpan.org
Copyright (c) 2003 by Eric J. Roode. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
If you have suggestions for improvement, please drop me a line. If you make improvements to this software, I ask that you please send me a copy of your changes. Thanks.
To install Function::ID, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Function::ID
CPAN shell
perl -MCPAN -e shell install Function::ID
For more information on module installation, please visit the detailed CPAN module installation guide.