-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpollcsv.pl
39 lines (33 loc) · 908 Bytes
/
pollcsv.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
use strict;
use 5.10.0;
$/ = "";
my $tag = "POLL";
## Decide here how closely to match tag
## Fancier would be to make tag an array pointer and loop through it
while (<>){
## next unless s/^\s*$tag\b\s*//;
next unless s/$tag\b\s*//;
chomp;
## Optionally have a pipe separating the lecture question from the everywhere question
## 2018 Mar 01 (Thu) Experimenting with ? divider as well. Why not?
## ? Only works if there are two of them.
## Don't have two ?s and also a |
s/.*[|]//s;
s/.*[?]\s*(.*[?])/$1/s;
s/\s*\n\s*/ /g;
## Choices start after .?:
my ($ques, $choices) = /(.*?[.?:])(.*)/;
# say "Ques: $ques";
# say "Choice: $choices";
## … split by ;
my @choices = split /;\s*/, $choices;
# @choices = map {s/.*/"$&"/} @choices;
print "Poll, ";
if (@choices>1){
print "Multiple choice, ";
} else {
print "Open-ended, ";
}
print $ques . ', ';
say join ", ", @choices;
}