Dear Monks,
I am generating perl code from a source perl file, the output is a mix of my generated code and the original source. So that possible errors can keep track of where I am in the original file, I'm outputting #line directives referring to the source file.
The problem is that once I've output a few lines of the original source, I'd like to switch back to having error messages refer to the current file; something like #line __LINE__ __FILE__. I haven't been able to find out how to do this or if it's at all possible.
If you have any ideas that'd be great!
Note: The functions which generate the code don't know what file they are writing to, and keeping track of the current output line seems like a big hassle, so generating #line directives for my own code isn't really possible. The only hack I've been able to come up with so far is generating the file with "#line __LINE__ __FILE__", and then in a second step doing
perl -i -pe 'if(/^#\s*line/) { s/__LINE__/$.+1/e; s/__FILE__/$ARGV/; }' -- generated.plBut this isn't really completely satisfactory either since now the filename is fixed to that value...
In reply to Reset the effect of #line by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |