-
Notifications
You must be signed in to change notification settings - Fork 11
/
test-t.pl
51 lines (42 loc) · 1.11 KB
/
test-t.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
47
48
49
50
51
#!raku
use v6;
use Text::CSV;
sub MAIN (Bool :$getline, Bool :$getline_all, Bool :$hyper, Bool :$race) {
my atomicint $sum = 0;
if $getline_all {
my $csv = Text::CSV.new;
$sum = [+] $csv.getline_all($*IN)».map(*.elems);
}
elsif $getline {
my $csv = Text::CSV.new;
while $csv.getline($*IN) {
$sum += $csv.fields.elems;
}
}
elsif $hyper {
# see https://irclog.perlgeek.de/perl6-dev/2017-10-20#i_15329645
@*ARGS.pop;
lines.hyper.map: {
my $csv = once Text::CSV.new;
$csv.parse($_);
$sum ⚛+= $csv.fields.elems;
}
}
elsif $race {
# see https://irclog.perlgeek.de/perl6-dev/2017-10-20#i_15329645
@*ARGS.pop;
lines.race.map: {
my $csv = once Text::CSV.new;
$csv.parse($_);
$sum ⚛+= $csv.fields.elems;
}
}
else {
my $csv = Text::CSV.new;
for lines() {
$csv.parse($_);
$sum += $csv.fields.elems;
}
}
$sum.say;
}