[Pdx-pm] Newbie question ... built-in for subroutine name?

Christian Brink cb at onsitetech.com
Thu Jul 25 16:53:39 CDT 2002


You can use caller in the foo sub to get the calling sub.

http://www.perldoc.com/perl5.6.1/pod/func/caller.html

Christian Brink
CTO 
ONSITE! Technology
www.onsitetech.com
503.233.1418
cb at onsitetech.com

Taking e-Business and Internet Technology To The Extreme! 





> -----Original Message-----
> From: pdx-pm-list-admin at mail.pm.org
> [mailto:pdx-pm-list-admin at mail.pm.org]On Behalf Of Earthlink
> Sent: Thursday, July 25, 2002 1:18 PM
> To: pdx-pm-list at pm.org
> Subject: [Pdx-pm] Newbie question ... built-in for subroutine name?
> 
> 
> I'm trying to find the perl built-in variable for the current 
> subroutine name (the analog to __FUNCTION__ in gcc), so that I 
> can pass the name to a calling function, as in 
> the code below. I've looked through the Coriolis and O'Reilly 
> texts, and at several on-line FAQs. Anyone know what it's called?
> 
>     sub foo
>     {
>         my ($callerName) = @_;
>         printf("foo called from $callerName\n");
>     }
> 
>     sub callingFxn
>     {
>         my $currentFxnName = ???;
>         foo($currentFxnName);
>     }
> 
> 
> _______________________________________________
> Pdx-pm-list mailing list
> Pdx-pm-list at mail.pm.org
> http://mail.pm.org/mailman/listinfo/pdx-pm-list



More information about the Pdx-pm-list mailing list