Re: Perl Special Variable Containing the name of the method currently in?
- From: "A. Sinan Unur" <1usa@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 May 2008 18:19:35 GMT
Nigel <nigelstuart@xxxxxxxxx> wrote in news:de8822a9-7087-4006-a8ef-
fd8c4b7e758a@xxxxxxxxxxxxxxxxxxxxxxxxxxxx:
Just out of curiosity.
Is there a way to get the name of the subroutine Perl is currently in
when it is running?
For example, if I have a subroutine declared with the name sub
helloWorld, is there any way from within that subroutine to
programmatically get 'helloWorld' without having to hardcode it?
#!/usr/bin/perl
use strict;
use warnings;
sub whatismyname { (caller 1)[3] }
sub iknowmyname {
my $name = whatismyname();
print "My name is '$name'\n";
}
iknowmyname();
__END__
Make sure to read perldoc -f caller
Sinan
--
A. Sinan Unur <1usa@xxxxxxxxxxxxxxxxxxx>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
.
- References:
- Prev by Date: Re: Need help with a simple (I think) Perl script
- Next by Date: Re: How to make input user and password in perl script started on web?
- Previous by thread: Re: Perl Special Variable Containing the name of the method currently in?
- Next by thread: Win32::IE::Mechanize can't upload
- Index(es):
Relevant Pages
|