[Israel.pm] Getting the function name
Ephraim Dan
E.Dan at F5.com
Thu Aug 18 05:04:29 PDT 2005
Not all subroutines have names.
my $coderef = sub { print( (caller 0)[3] ); };
$coderef->();
This will print:
main::__ANON__
That's an anonymous subroutine.
- Ephraim
> -----Original Message-----
> From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf
> Of Gábor Szabó
> Sent: Thursday, August 18, 2005 14:55
> To: Perl in Israel
> Subject: Re: [Israel.pm] Getting the function name
>
> (caller(0))[3]
>
>
> On 8/18/05, Yaron Golan <yargolan at gmail.com> wrote:
> > Hi,
> > I am trying to verify that I have passed over all the functions in the
> code.
> > Is there a quick way to tell the function name I am in?
> >
> > e.g.
> >
> > &function1;
> >
> > sub function1 {
> > print "function 'function1' - start\n";
> > ... do something ...
> > print "function 'function1' - end\n";
> > }
> >
> > _______________________________________________
> > Perl mailing list
> > Perl at perl.org.il
> > http://perl.org.il/mailman/listinfo/perl
> >
> >
>
>
> --
> Gábor Szabó
> Perl in Israel http://www.pti.co.il
> 08-975-2897 054-4624648 AIM: gabor529
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
More information about the Perl
mailing list