--- Rajeev Rumale <[EMAIL PROTECTED]> wrote:
> Thanks  Dwalu,
> 
> But the what i need is the grep the name of the sub which is calling the
> loging sub.
> As you have suggested "caller" only gives only the name of current sub
> routine that is &debugLogger it self.
> And I had to do call the "caller" before calling the "debugLogger" and pass
> all the info to it.
> 
> What i need is the the name of the sub rotuine which is "calling" the sub
> "&debuLogger".

Pass it as an argument:
 
sub someSub{
    statement 1;
    statement 2;
    statement 3;
    &debugLogger($message, (caller(0))[3]);
    &anotherSub;
}

sub anotherSub{
    statement 1;
    statement 2;
    statement 3;
    &debugLogger($message, (caller(0))[3]);
}


sub debugLogger {
    my ( $message, $sub_name ) = @_;

    open (LOGGER, ">> my.log") || die " unable to ope the log file";
    print LOGGER "\n----------------------------------------";
    print LOGGER "\nCalled from $sub_name.";
    print LOGGER "\n$message";
    print LOGGER "\n----------------------------------------";
    close LOGGER;
}

Cheers,
Curtis Poe

=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to