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.
In reply to Changing "filename" of eval-ed code by perlancar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |