| Author |
line number on error condition
|
|
| tewilk@gmail.com 2006-09-21, 6:58 pm |
| can someone give me an example of how I can print the line number of
the current place in my perl script when creating an error condition?
For example, lets say I'm reading a configuration file and a setting
I'm expecting to be in the file is not there so I want to end the
execution of the script. How do I print the line number of the current
or last executed line of code?
Thanks!
Terry
| |
| usenet@DavidFilmer.com 2006-09-21, 6:58 pm |
| tewilk@gmail.com wrote:
> can someone give me an example of how I can print the line number of
> the current place in my perl script when creating an error condition?
print "Oops - big booboo on line " . __LINE__ . "\n";
or
print "Oops - big booboo on line @{[__LINE__]}\n";
--
David Filmer (http://DavidFilmer.com)
| |
| Uri Guttman 2006-09-21, 6:58 pm |
| >>>>> "u" == usenet <usenet@DavidFilmer.com> writes:
u> tewilk@gmail.com wrote:[color=darkred]
u> print "Oops - big booboo on line " . __LINE__ . "\n";
u> or
u> print "Oops - big booboo on line @{[__LINE__]}\n";
warn will do that if its arg list doesn't end with a \n (just like die
will). so warn 'oops - big booboo' is all you need.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
| |
| tewilk@gmail.com 2006-09-22, 7:57 am |
| Thanks for all replies... worked great!
Uri Guttman wrote:
>
> u> tewilk@gmail.com wrote:
>
> u> print "Oops - big booboo on line " . __LINE__ . "\n";
> u> or
> u> print "Oops - big booboo on line @{[__LINE__]}\n";
>
> warn will do that if its arg list doesn't end with a \n (just like die
> will). so warn 'oops - big booboo' is all you need.
>
> uri
>
> --
> Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
> Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
|
|
|
|