On Tue, Dec 2, 2008 at 09:11, Deviloper <[EMAIL PROTECTED]> wrote:
> Hi!
>
> Is there a special variable or trick to get the name of the current scope or
> subroutine name?
>
> Thanks,
> B.
>
The caller* function will tell you information about the call stack
(including the current function):
#!/usr/bin/perl
use strict;
use warnings;
sub foo {
my $f = (caller 0)[3];
print "the current function is $f\n";
}
foo()
Unfortunately, it can't return a useful name for anonymous functions.
* http://perldoc.perl.org/functions/caller.html
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/