> my $caller=???????????? You are so close.
my $caller = caller; Look at "perldoc -f caller" for more info on the different ways to use it. Please note that sometime the info you get from caller isn't the real caller. If you call your debug() function right before a return statement it is possible that optimizations by the Perl compiler can optimize the calling info away. You should be able to defeat the optimization by making sure that some operation happens after the call to your debug() method. Anyway, I just wanted to mention it because when I did something similar I was going nuts trying to figure out why caller wasn't returning what it should. Rob -----Original Message----- From: Gary Stainburn [mailto:[EMAIL PROTECTED] Sent: Monday, January 19, 2004 8:09 AM To: [EMAIL PROTECTED] Subject: name of calling function Hi folks, In the back of my mind I seem to think that you can find out where a function was called from. What I'm after is: my %_DEBUG={'new'=>1,'load_file'=>0}; sub debug { my $caller=???????????? return (defined $_DEBUG{$caller} ? $_DEBUG{$caller} : 0; } sub new { # create new track object print "calling Trainset::Track::new\n" if &debug; .... } Is this possible? -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>