How can I get the __LINE__ for calling function?
perl
Solution
Check `caller` function,
sub logm {
my ($msg) = @_;
my ($package, $filename, $line) = caller;
print "'$msg' from file:$filename; line:$line\n";
}
logm("message");
Problem
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. Addendum (in case that link fails eventually) 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__; ```