/[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

Annotation of /trunk/data/convert.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (hide annotations)
Fri May 20 21:29:39 2005 UTC (19 years ago) by dpavlin
File MIME type: text/plain
File size: 989 byte(s)
make test database from IMDB's trivia

1 dpavlin 6 #!/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     close($t);
54     $trivia = '';
55     @qv = ();
56     $in = 0;
57     } else {
58     print "#$_\n";
59     }
60    
61     }
62    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26