I have a debug log subroutine that I copy and paste into different Perl modules as I am working on them. It occurred to me that it would be very useful to log the line numbers to the file as a better means of keeping track of what a script is doing, and finding the location using the vi editor. This might be a stupid question or simply one for some genius out there to answer:


I would like something like


#!/usr/bin/perl -w


---- code ----

&DebugLog("I am at line: $line_number_in_the_script");

--- more code -----


Sub DebugLog() { my ($line) = @_; print "$line\n";

}


I could paste these throughout my code and not worry about where they end up.


Any ideas?

Thanks,

Gregg Allen









Reply via email to