/[pgestraier]/trunk/data/convert.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/data/convert.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations)
Fri May 20 22:01:19 2005 UTC (18 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1040 byte(s)
more work on testing framework

1 #!/usr/bin/perl -w
2
3 use strict;
4
5 open(my $t, "gzip -cd trivia.list.gz |") || die "can't open trivia.list.gz: $!";
6
7
8 my $header = 1;
9 my $title = '';
10 my $in = 0;
11 my $trivia = '';
12 my @qv;
13
14 sub qv {
15 my $t = shift || return;
16
17 sub qv_print {
18 my $v = shift || return '';
19 $v =~ s/(.*)\s*,\s*(.+)/$2 $1/g;
20 push @qv, $v;
21 return '';
22 }
23 $t =~ s#([_'])([^\1]+?)\1 \(qv\)#qv_print($2)#ge;
24 }
25
26 my $i = 0;
27
28 while(<$t>) {
29 if (/^=====+/) {
30 $header = 0;
31 next;
32 }
33 next if $header;
34
35 if (/^#\s+(.*)\s*$/) {
36 $title = $1;
37 print "# title=$title\n";
38 next;
39 } elsif (/^-\s(.*)\s*$/) {
40 $in = 1;
41 $trivia = "$1\n";
42 qv($1);
43 } elsif (/^\s\s(.*)\s*$/) {
44 $trivia .= "$1\n";
45 qv($1);
46 } elsif (/^$/ && $in) {
47 $i++;
48 print "$i ";
49 open(my $t, "> trivia/$i.est") || die "can't open $i.est: $!";
50 print $t '@title='.$title."\n";
51 print $t '@qv='.join(",", @qv),"\n\n" if (@qv);
52 print $t "$trivia\n";
53 print $t "\t$title\n\t", join("\n\t", @qv),"\n";
54 close($t);
55 $trivia = '';
56 @qv = ();
57 $in = 0;
58 } else {
59 print "#$_\n";
60 }
61
62 }
63

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26