in reply to Re: Re: Is there any way of determining the current line number of a child process while it is running?
in thread Is there any way of determining the current line number of a child process while it is running?

I can see how adding print __LINE__ to the end of each line of your scripts would be a time consuming, boring and repetative task... Hang on, that sounds like an ideal application for a computer:)

Install Filter::Simple, put a copy of the following snippet into .../site/lib/Filter/LineTrace.pm

package Filter::LineTrace; use Filter::Simple; FILTER_ONLY code => sub { s[;\s*$][;print STDERR __LINE__;]mg; }, ; # Replace the next line with 1; print STDERR 'Filter::LineTrace loaded';

And add use Filter::LineTrace; to the top of your scripts and each line that ends in a /;\s*\n/ will now print its line number to STDERR.

As-is, the line numbers don't always match the lines exactly, but they are only usually out by 1 if at all, and not every line ends in a semicolon, so they don't all get traced, but it may be enough for your purpose.

If not, you could add addition substitutions to catch those that end in { or } etc. as required.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.
  • Comment on Re: Re: Re: Is there any way of determining the current line number of a child process while it is running?
  • Select or Download Code