nneul has asked for the wisdom of the Perl Monks concerning the following question:
Sometimes I get the correct info, where the function matches up with function_basefile. But other times, it doesn't seem to match. The function is correct, but the filename is from the caller's caller. The reason for 1,2 is that the call trace looks like:(undef, $function_basefile, $function_line, $function) = caller(1); (undef, $caller_basefile, $caller_line, $caller) = caller(2);
For that example, I want to see sub2 as the function, and sub1 as the caller, with the appropriate filenames. Here's an example:main -> sub1 -> sub2 -> UsageLogger
ADSObject::new should have been from ADSObject.pm, not Exchange.pm. Exchange::new should have been from Exchange.pm. I saw the note in caller's documentation about losing call frames due to optimization for N > 1, but that doesn't seem to apply here, and I would expect to lose the subroutine call as well, not just the filename.Mon Mar 7 07:09:12 2005 syscron.cc.umr.edu/syscron.cc.umr.edu unixdb: + script = /afs/umr.edu/software/unixdb/bin/load-email-usage-userid.pl + function = UMR::SysProg::ADSObject::new function_file = /afs/umr +.edu/software/umrperl/libs/UMR/SysProg/Exchange.pm function_line += 43 caller = UMR::SysProg::Exchange::new caller_file = /afs/ +umr.edu/software/unixdb/bin/load-email-usage-userid.pl caller_l +ine = 8 cwd = /afs/umr.edu/software/unixdb
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Partially wrong info from caller()
by tilly (Archbishop) on Mar 14, 2005 at 17:18 UTC |