-
Notifications
You must be signed in to change notification settings - Fork 2
/
lines.pl
47 lines (34 loc) · 882 Bytes
/
lines.pl
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
#!/usr/bin/perl -w
use strict;
use warnings;
sub count($) {
my ($str, $l, $s) = (shift);
$l = ($str =~ tr/\n//);
$s = ($str =~ tr/;//);
return ($l, $s);
}
sub get_all($) {
local $/ = undef;
my @files = grep { -f } glob(shift);
join '', map { open my $fh, '<', $_; <$fh> } @files
}
my $csrc = get_all('src/*.cc');
my $ctest = get_all('src/test/*.cc');
my $jssrc = get_all('lib/*.js');
my $jstest = get_all('test/*.js');
my @cs = count($csrc);
my @ct = count($ctest);
my @js = count($jssrc);
my @jt = count($jstest);
format STDOUT_TOP =
Source Test Total
.
my ($label, $a, $b, $c, $d);
format STDOUT =
@<<<<<<< @##### @##### @#####
$label, $a, $b, $c,
.
$label = 'lines', $a = $cs[0]+$js[0], $b = $ct[0]+$jt[0], $c = $a+$b;
write;
$label = 'semis', $a = $cs[1]+$js[1], $b = $ct[1]+$jt[1], $c = $a+$b;
write;