--- Bram Kuijper <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Is there some type of equivalent to PHP's __FUNCTION__ magical
> constant
> in Perl, with which you can get the current function's name within
> the
> function's body?
>
> The list of perl predefined variables from Larry Wall's book does
> provide a __FILE__ constant, but apparently a __FUNCTION__ constant
> doesn't exist. What is the best way to get the function's name within
>
> the function's body in Perl?
The following will print out 'main::foo' (or whatever package the
function is in):
#!/usr/bin/perl
print foo();
sub foo {
return (caller(0))[3];
}
See 'perldoc -f caller' for more information.
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/