Basically, my question is this except for perl rather than PHP.
I know warn() manages it, but then again warn() is core perl, so I'd understand if it weren't generally possible.
have a function
sub logm
{
my ($msg, $line_no) = @_;
# ...
}
I would like to include __LINE__ (and __FILE__, but that's not necessary), but don't want to include it as a parameter each time as I currently do.
# This is attrocious
logm "That file handle is now closed", __LINE__;
| > In C#, you can use System.Diagnostics.StackTrace class to get the code's | > line number, function name, filename and other information. | > Hope this helps. rights. | > C++?
We can also write function call as a parameter to function. In the below code, first add (num1, num2) is evaluated, let the result of this be r1. The add (r1, num3) is evaluated. Let the result of this be r2. Finally add (r2, num4) is evaluated and its result is printed.
The call () method is a predefined JavaScript method. It can be used to invoke (call) a method with an owner object as an argument (parameter). With call (), an object can use a method belonging to another object. This example calls the fullName method of person, using it on person1:
The JavaScript call () Method The call () method is a predefined JavaScript method. It can be used to invoke (call) a method with an owner object as an argument (parameter). With call (), an object can use a method belonging to another object.
Check caller
function,
sub logm {
my ($msg) = @_;
my ($package, $filename, $line) = caller;
print "'$msg' from file:$filename; line:$line\n";
}
logm("message");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With