gg48gg has asked for the wisdom of the Perl Monks concerning the following question:

I know that there is die and warn, but I have a need to create my own subroutines for handling warnings, errors, fatal_errors, etc.

I am trying to print the line number for which the error occurred. Code is below, however, it prints the line number of the subroutine instead of the line number I meant......

I would like to have the code to print the correct line number within the subroutine, rather than passing __LINE__ to the subroutine. Is this possible?

open (FILE,"<","/etc/doesnotexist") || fatal_error("can't open /etc/do +esnotexist, sorry"); sub fatal_error { print STDERR "ERROR: ", @_," ",__LINE__; usage(); exit 1; }