Re: [Boston.pm] Changing line number reported by errors
Uri Guttman <uri-X/[email protected]> Fri, 25 Oct 2019 12:22:41 -0400
| Newsgroups | gmane.comp.lang.perl.perl-mongers.boston |
|---|---|
| Organization | Perl Hunter |
| Message-ID | <[email protected]> |
On 10/25/19 12:19 PM, Morse, Richard E.,MGH wrote: > On Oct 25, 2019, at 12:14 PM, Uri Guttman <[email protected]> wrote: > >> On 10/25/19 12:03 PM, Morse, Richard E.,MGH via Boston-pm wrote: >>> I haven’t tried this, but according to the documentation for $. >>> ($INPUT_LINE_NUMBER), you should be able to assign a value to this which >>> Perl will use for reporting: >> another idea: >> >> __LINE__ is a compiler generated value of the current line. so you could >> do something like this: >> >> print $@, 'error at line: ', __LINE__ ; >> >> i recall something can be done with # comments to also set a line number >> but i can't find it in the docs. the __LINE__ thing should be enough. > Maybe I misunderstood — I thought Greg was looking to change the reported > line number of the file he read the code from, not the line number of the > program running the slurped code. __LINE__ would be the right answer for > that, although I don’t know when it was introduced — I have a vague > recollection that it’s more recent… > my understanding (to be corrected by greg) is that an error in evaled perl code reports the line number in that code. he wants the line number of the eval call itself. he can use __LINE__ to get that when he checks the eval for any errors in the slurped in code. uri _______________________________________________ Boston-pm mailing list [email protected] https://mail.pm.org/mailman/listinfo/boston-pm