in reply to Conditionally executing debugging code

I needed to switch debugging messages on and off dynamically on secure FTP server (pain with uploading programs - needs password), so I did not want to change source code. Instead, if file  dbgviewmode.YES exist in my developer cgi-bin directory, messages are printed. To switch them off, I'll just rename file to  dbgviewmode.NO

Routine dbg_print prints debug message (in smaller font and dark red color) together with program line and file name where it was called from.

sub is_dbgview { return -e 'dbgviewmode.yes'; } sub dbg_print (@) { my @inpar = @_; return 0 if not is_dbgview(); # use caller() to figure out out procedure call stack # with program names and line numbers my $caller = ....; print '<FONT COLOR=firebrick SIZE=-1>', "DBG message from $caller...:, @inpar, '</FONT>'; }
You may want to print some comments about process status using dbg_print as well. Easy to see them if needed