On Monday 19 Jan 2004 1:09 pm, Gary Stainburn wrote: > 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?
Sorted it 5 minutes after sending the post - typical. my $caller=(caller(1)}[3]; # get full name $caller=~s/^.*:://; # remove package name -- 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>