perlancar has asked for the wisdom of the Perl Monks concerning the following question:
I use quite a bit of generated code in my program (meaning Perl code that is assembled in a string then eval-ed), for example, when generating argument validator code using Data::Sah.
This turns out to be rather annoying when debugging warning/error messages. Perl only shows the filename as "(eval NUMBER)", for example:
perl -wE'eval "1+1; 1"; eval "\n; 1+1; 2"' Useless use of a constant (2) in void context at (eval 1) line 1. Useless use of a constant (2) in void context at (eval 2) line 2.
It would be slightly more helpful if there were a way to change the filename into something more descriptive, so the warn/error message can be something like:
Useless use of a constant (2) in void context at (validator code for X + generated by Foo/Bar.pm line 234) line 1. Useless use of a constant (2) in void context at (validator code for Y + generated by Foo/Baz.pm line 99) line 2.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Changing "filename" of eval-ed code
by Discipulus (Canon) on May 20, 2016 at 08:28 UTC | |
by perlancar (Hermit) on May 20, 2016 at 12:07 UTC | |
|
Re: Changing "filename" of eval-ed code
by Anonymous Monk on May 20, 2016 at 08:20 UTC | |
by Discipulus (Canon) on May 20, 2016 at 08:41 UTC | |
by davido (Cardinal) on May 20, 2016 at 15:12 UTC | |
by perlancar (Hermit) on May 20, 2016 at 12:13 UTC |