Forums.ATC.no
Teknisk => Generelt teknisk => Emne startet av: ATC på 16. Januar 2009, 16:21 pm
-
When troubleshooting perl code, is it possible to see where a subroutine was called from?
-
Yes. The proper way to do this is using the Carp module. However, you can examine the code stack via the caller() function. Implement your own full-blown stack tracer, or simply use code such as this to get a quick clue:
my ($pkg, $file, $line, $sub) = caller(0); print "$sub was called from $pkg in $file line $line\n";
The output will look something like this:
main::subroutine called from main in ./callertest line 8