blob: 82a4fd84cbfc9a2d91ccd1a2509f09c245728822 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/perl
#
# Count the number of Debian consultants
#
# Written by: Behan Webster <behanw@pobox.com>
#
$filename = 'consultant.data';
$comment = '^#\s*Consultant:\s*(.*)\s*$';
# Read in file
open( FILE, "<$filename" ) || die "$filename: $!\n";
my $buffer = "";
my $outfile = "consultant.inc";
my $count = 0;
my %country;
my $list ='';
# Count consultants/countries
while ( <FILE> ) {
chomp;
if( /$comment/ ) {
$count++;
$country{$1}++;
}
}
@_ = keys %country;
my $number = $#_ + 1;
close( FILE );
# Print results
foreach ( sort keys %country ) {
printf "%-4d %s\n", $country{$_}, $_;
$buffer .= sprintf ("<define-tag %s_count>%d</define-tag>\n", $_, $country{$_});
$list .= "$_-$country{$_} ";
}
# Report numbers and update file in buffer
print "Number of consultants: $count\n";
print "Number of countries: $number\n";
$buffer .= sprintf ("<define-tag total_consultant>%d</define-tag>\n", $count);
$buffer .= sprintf ("<define-tag total_country>%d</define-tag>\n", $number);
$buffer .= sprintf ("<define-tag list_country>%s</define-tag>\n", $list);
open (FILE, ">$outfile") || die "$outfile: $!\n";
print FILE $buffer;
close (FILE);
|