perldoc Benchmark #### vi \perl\lib\Benchmark.pm #### BEGIN { use Benchmark; my ($oldb, $newb); # inside BEGIN for closure sub mybench { return unless ($opt_b); $newb = new Benchmark; if ($oldb) { # i.e. don't run first time through print timediff($oldb, $newb); } $oldb = $newb; } } Getopt::Std; getopts('b'); mybench(); # some code here mybench(); # some more code here mybench(); #### mycode.pl -b #### perl -lne 'print unless /^\s*mybench();/' myscript.pl > production.pl