CoCalc Public Fileswww / cgi-bin / openwebmail / misc / test / profdel.plOpen with one click!
Author: William A. Stein
1
#!/usr/bin/perl
2
#
3
# this uty removes the prof log line at the begining of all subroutine
4
# which were added by the profadd.pl uty,
5
#
6
7
use strict;
8
if ($#ARGV<0) {
9
print "profdel file1 file2 ...\n";
10
exit;
11
}
12
13
my $updatedfile=0;
14
my $totalremoval=0;
15
foreach my $script (@ARGV) {
16
my $content='';
17
my $removal=0;
18
print "remove debug code from $script ...";
19
open (F, $script);
20
while (<F>) {
21
my $line=$_;
22
if ($line=~/^require "misc\/test\/gettimeofday.pl"/) {
23
$removal++;
24
} elsif ($line=~/^ow::tool::timeofday_init/) {
25
$removal++;
26
} elsif ($line=~/ow::tool::log_time\("PROF", ow::tool::/) {
27
$removal++;
28
} else {
29
$content.=$line;
30
}
31
}
32
close(F);
33
34
if ($removal) {
35
if (open (F, ">$script")) {
36
print F $content;
37
close(F);
38
$updatedfile++;
39
$totalremoval+=$removal;
40
print "$removal line removed\n";
41
} else {
42
print "update err!\n";
43
}
44
} else {
45
print "\n";
46
}
47
}
48
49
print "$updatedfile file updated (total $totalremoval line removed)\n";
50