The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Function::ID - Variables to let functions know their names.

VERSION

This documentation describes version 0.02 of Function::ID, March 29, 2003.

SYNOPSIS

 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!

DESCRIPTION

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.

Both these variables contain undef in the main portion of a program's code (ie, outside of any function body).

VARIABLES

$this_function

$this_function returns the fully-qualified name of the current function, including its package. For example: 'Foo::Bar::Baz::my_function'.

$this_fn

$this_fn returns the name of the current function, with no package name. For example: 'my_function'.

EXPORTS

This module exports the following symbols into the caller's namespace:

 $this_function
 $this_fn

REQUIREMENTS

 Carp.pm (included with Perl)

AUTHOR / COPYRIGHT

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.