# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # &Vopt("5myname.log"); # # Set the verbosity from various environment variables. The value may # # be a verbose level (1 digit), plus an optional output file name. # # The file V is opened to the file, if any, or STDERR by default. The # # default value for the verbosity level is 1, which generally means # # to produce only serious error messages. # # # # Here's how this routine is typically called: # # ($P = $0) =~ s'.*/'' unless defined($P); # # &Vopt($ENV{"V_$P"} || $ENV{"D_$P"} || $ENV{"T_$P"} || '1'); # # That's for when you want to call this a "verbose" and "debug" and # # "trace" facility. I mostly just use the V_$P environment variable. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # sub Vopt { $Vopt = shift || '1'; $V = 1 unless defined $V; print "
Vopt: Vopt=\"$Vopt\"
\n" if $V>2; if ($Vopt =~ /^(\d+)(.+)$/) { $V = $1; $Vfil = $2; if (!open(V,">>$Vfil")) { print V "$P: Can't write \"$Vfil\" ($!)\n" if $V>0; open(V,">>&STDERR"); } else { open(STDERR,">>&V"); } } else { $V = $Vopt; open(V,">>&STDERR"); } select V; $| = 1; select STDOUT; $| = 1; $esep = '=' x 70; $hsep = '-' x 70; print V "\n$P $esep\n" if $V>1; print V "$P started with V=$V [pid=$$] ", `date` if $V>1; } 1; # Report success in loading this file.