in reply to controlling script verbosity
Assuming you're going to code this yourself, and not use a module... ;-)
First, you have a verbosity level setting, say $verbosity, whose value is set by the number of -v switches (or whatever).
You also define a function for producing the output which takes, in addition to the message content, a number which is the "severity" of the message. If this number is less that the verbosity level, the message is printed, otherwise, not. (Note that higher numbers indicate lower severity.) Example:
my $verbosity = 0; GetOptions( 'verbose+' => \$verbosity, ); sub report { my $severity = shift; print @_ if $severity <= $verbosity; } report( 2, "reached ".__FILE__.":".__LINE__."\n" );
To make it really useful, you'd want to have versions that warn and die as well.
|
|---|