Perl borrows the C preprocessors "#file" and "#line" directives to change the file name and line number reported.
andrew@localhost:~$ perl -e 'use warnings; return' Can't return outside a subroutine at -e line 1. andrew@localhost:~$ perl -e '#line 266' -e 'use warnings; return' Can't return outside a subroutine at -e line 266. andrew@localhost:~$ If you have the perl script embedded in a larger file for some reason (like the way one might embed a Windows script might be embedded in a .CMD file to be executable) it is often helpful to set the line number, as Perl starts counting line numbers from the "#!/usr/bin/perl" line. Keep in mind that #line directives specifies what perl should report as the next line's line number. (so "#line 8" will be on line 7, which will confuse someone who doesn't understand the line directives and thinks it is an odd comment in the code.) On Fri, Oct 25, 2019 at 12:27 PM Uri Guttman <u...@stemsystems.com> wrote: > On 10/25/19 12:22 PM, Uri Guttman wrote: > > 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. > > another idea: > > use carp to report the error (or one of the carp subs). check the eval > for an error and carp $@. it should report the current line number of > the eval. > > uri > > _______________________________________________ > Boston-pm mailing list > Boston-pm@pm.org > https://mail.pm.org/mailman/listinfo/boston-pm > _______________________________________________ Boston-pm mailing list Boston-pm@pm.org https://mail.pm.org/mailman/listinfo/boston-pm