in reply to Re^2: How Do I Get the Line Number In My Error Message?
in thread How Do I Get the Line Number In My Error Message?
If your program has more than one file (for example, if your code is a perl module), __FILE__ is more useful; $0 will tell you the name of the file that perl started running, but __FILE__ will tell you the file where you code is currently running. If you use the commands "require", "do", "use", __FILE__ will keep track of where the code came from: it's very handy.
Also, notice that it's __FILE__ (with two underscores before and after the word), not _FILE_ (with one underscore).
You might want to look at the module called "Carp": if you say "use Carp"; and then use the function "carp" where you would use the function "warn", you'll get messages that include the current line number, all the functions called to reach the current function, with file names and line numbers.
Good Luck! :-)
--
Ytrew
|
|---|