Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > how to get the caller's information?

Reply
Thread Tools

how to get the caller's information?

 
 
Brady
Guest
Posts: n/a
 
      07-15-2006
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:ebug("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

 
Reply With Quote
 
 
 
 
brian d foy
Guest
Posts: n/a
 
      07-15-2006
In article <(E-Mail Removed) .com>,
Brady <(E-Mail Removed)> wrote:


> how to get the caller's place?


have you tried the caller() builtin?

perldoc -f caller

--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
 
DJ Stunks
Guest
Posts: n/a
 
      07-15-2006
Brady wrote:
> 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:ebug("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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Serious cache problem - Page_Load get never get called !!! Ryan Park ASP .Net 2 01-03-2005 05:52 PM
Re: use anonymous but get get an authentication box Curt_C [MVP] ASP .Net 2 09-21-2004 06:39 PM
use anonymous but get get an authentication box =?Utf-8?B?U2hhcmlm?= ASP .Net 0 09-21-2004 01:01 PM



Advertisments