how to get the caller's information?

B

Brady

hi, all,

i want to have a sub debug, which takes a string as a parameter, and
print the file name and line number of the place invoking the sub.

I tried to :
in main.pl:

if ($something_is_wrong) {
Mylib::Debug("wrong!!!");
}

in Mylib.pm

sub Debug()
{
print STDERR, "__FILE__:__LINE__", @_;
}

but, the __FILE__ and __LINE__ is the Mylib.pm and the line number of
Mylib.pm.

how to get the caller's place?


thanks & best wishes!

/Brady
 
D

DJ Stunks

Brady said:
hi, all,

i want to have a sub debug, which takes a string as a parameter, and
print the file name and line number of the place invoking the sub.

I tried to :
in main.pl:

if ($something_is_wrong) {
Mylib::Debug("wrong!!!");
}

in Mylib.pm

sub Debug()
{
print STDERR, "__FILE__:__LINE__", @_;
}

but, the __FILE__ and __LINE__ is the Mylib.pm and the line number of
Mylib.pm.

how to get the caller's place?

use Carp;

-jp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top