|Think about Loose Coupling|
How to determine current line executing in Scriptby bearslumber (Novice)
|on Dec 04, 2008 at 12:08 UTC||Need Help??|
bearslumber has asked for the
wisdom of the Perl Monks concerning the following question:
I am trying to find a way to dynamically determine the current line being executed in my script.
I have a batch script which I accumulate a progress report or log whilst it is running and then output the log to a file on completion. I wish to add the current line number being executed in the script to each instance in the report
The following describes a snippet of code to demonstrate my requirement. I have annotated the code with line numbers for demonstration purposes
The following demonstrates the hard coded method at line 31, but if there is a way of determining this dynamically then this would reduce the need to have to manually update the hard coded value whenever the script is modified.
I envisage substituting line 31 as follows:
push (@log, "Read $file not successfull" . &function_returning_current_line) ;
or anything similar; i.e. Get a near enough line number before the call to push etc
Any help would be greatly appreciated
Lucas Redding AKA Bearslumber