For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2007 > Getting sub routine name as string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Getting sub routine name as string
Rodrick Brown

2007-08-02, 7:00 pm


How can I get the subroutine calling name as a string?=20

Ie. Sub foo =7B =7D I would like to get foo back as a string.=20


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =
- - - - - - -

This message is intended only for the personal and confidential use of the =
designated recipient(s) named above. If you are not the intended =
recipient of this message you are hereby notified that any review, =
dissemination, distribution or copying of this message is strictly =
prohibited. This communication is for information purposes only and =
should not be regarded as an offer to sell or as a solicitation of an =
offer to buy any financial product, an official confirmation of any =
transaction, or as an official statement of Lehman Brothers. Email =
transmission cannot be guaranteed to be secure or error-free. Therefore, =
we do not represent that this information is complete or accurate and it =
should not be relied upon as such. All information is subject to change =
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within =
this communication (including any attachments) is not intended or written =
to be used and cannot be used for the purpose of (i) avoiding U.S. tax =
related penalties or (ii) promoting, marketing or recommending to another =
party any transaction or matter addressed herein.


Mr. Shawn H. Corey

2007-08-02, 7:00 pm

Brown, Rodrick wrote:
> How can I get the subroutine calling name as a string?
>
> Ie. Sub foo { } I would like to get foo back as a string.


See `perldoc -f caller`


--
Just my 0.00000002 million dollars worth,
Shawn

"For the things we have to learn before we can do them, we learn by doing them."
Aristotle
Adriano Ferreira

2007-08-02, 7:00 pm

On 8/2/07, Brown, Rodrick <rodrick.brown@lehman.com> wrote:
>
> How can I get the subroutine calling name as a string?
>
> Ie. Sub foo { } I would like to get foo back as a string.


Sub::Identify may be useful.
http://search.cpan.org/dist/Sub-Identify
Adriano Ferreira

2007-08-02, 7:00 pm

On 8/2/07, Mr. Shawn H. Corey <shawnhcorey@magma.ca> wrote:
> Brown, Rodrick wrote:
>
> See `perldoc -f caller`


Shawn is absolutely right. The builtin "caller" is what you need to
get the subroutine name you're in and the callers all the way up.

Sub::Identify is when you want to go from a coderef to the subroutine name.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com