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".
Consider the following subs
----------------
sub someSub{
statement 1;
statement 2;
statement 3;
&debugLogger($message);
&anotherSub;
}
sub anotherSub{
statement 1;
statement 2;
statement 3;
&debugLogger($message);
}
sub debugLogger {
my $message = "@_";
$sub_name = ""; # Get the subroutine name.This is what i need to grep.
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;
}
So if the sub "someSub" is called
The information I expect in the file is .
------------------------------------------------
called from someSub
Here is the message.
------------------------------------------------
------------------------------------------------
called from anotherSub
Here is the message.
------------------------------------------------
with regards
Rajeev Rumale
----------------------------------------------------------------------------
-----
Artificial Intelligence is no match for Natural Stupidity.
----------------------------------------------------------------------------
-----
----- Original Message -----
From: "Dwalu Z. Khasu" <[EMAIL PROTECTED]>
To: "Rajeev Rumale" <[EMAIL PROTECTED]>
Cc: "Beginners-Cgi (E-mail)" <[EMAIL PROTECTED]>
Sent: Monday, August 06, 2001 3:47 PM
Subject: Re: getting the calling function name.
> See perldoc -f caller
>
>
> On Mon, 6 Aug 2001, Rajeev Rumale wrote:
>
> =>Hello Every Body,
> =>
> =>I need some help.
> =>I am using a sub routine to log all the messages to be used for
debugging
> =>purpose.
> =>ie. &debugLogger($debug_message);
> =>Since very similare kind of messages are genrated at serveral places, I
add
> =>the function name.
> =>i.e., &debugLogger("inside xxxxx \n $debug_message");
> =>
> =>I feel it would be better as a prgramming style if sub debugLog is able
to
> =>find the name of the "calling function" or the name of the function
> =>"calling" this sub and genrate the appropriate message.
> =>
> =>
> =>with regards
> =>
> =>
> =>Rajeev Rumale
> =>
> =>
> =>***********************************************************
> => "The human race has one really effective weapon, and that is
laughter."
> =>***********************************************************
> =>
> =>
> =>
> =>--
> =>To unsubscribe, e-mail: [EMAIL PROTECTED]
> =>For additional commands, e-mail: [EMAIL PROTECTED]
> =>
> =>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]