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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Line numbers
by tobyink (Canon) on Mar 16, 2012 at 23:02 UTC | |
by LanX (Saint) on Mar 16, 2012 at 23:18 UTC | |
by tobyink (Canon) on Mar 16, 2012 at 23:33 UTC | |
by chromatic (Archbishop) on Mar 17, 2012 at 00:02 UTC | |
by tobyink (Canon) on Mar 17, 2012 at 00:12 UTC | |
| |
by LanX (Saint) on Mar 17, 2012 at 00:07 UTC | |
by gg48gg (Sexton) on Mar 17, 2012 at 01:46 UTC | |
| |
by LanX (Saint) on Mar 17, 2012 at 00:08 UTC | |
by repellent (Priest) on Mar 17, 2012 at 06:51 UTC | |
by gg48gg (Sexton) on Mar 16, 2012 at 23:12 UTC | |
Re: Line numbers
by Marshall (Canon) on Mar 16, 2012 at 23:54 UTC |
Back to
Seekers of Perl Wisdom