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

Diff of /trunk/data/convert.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by dpavlin, Thu May 26 13:57:32 2005 UTC revision 21 by dpavlin, Thu May 26 19:43:56 2005 UTC
# Line 14  my $in = 0; Line 14  my $in = 0;
14  my $trivia = '';  my $trivia = '';
15  my @qv;  my @qv;
16    
17    my ($all_years,$all_titles,$all_quotes);
18    
19  sub qv {  sub qv {
20          my $t = shift || return;          my $t = shift || return;
21    
22          sub qv_print {          sub qv_print {
23                  my $v = shift || return '';                  my $v = shift || return '';
24                  $v =~ s/(.*)\s*,\s*(.+)/$2 $1/g;  #               $v =~ s/(.*)\s*,\s*(.+)/$2 $1/g;
25                  push @qv, $v;                  push @qv, $v;
26                    $all_quotes->{$v}++;
27                  return '';                  return '';
28          }          }
29          $t =~ s#([_'])([^\1]+?)\1 \(qv\)#qv_print($2)#ge;          $t =~ s#([_'])([^_']+?)\1 \(qv\)#qv_print($2)#ge;
30  }  }
31    
32  my $i = 0;  my $i = 0;
# Line 37  while(<$t>) { Line 40  while(<$t>) {
40    
41          if (/^#\s+(.*)\s*$/) {          if (/^#\s+(.*)\s*$/) {
42                  $title = $1;                  $title = $1;
43                  if ($title =~ m#\s*\((\d+)\)\s*$#) {                  if ($title =~ m#^("*)(.*)\1\s*\((\d+)\)(:?\s*\(\w+\))*$#) {
44                          $year = $1;                          $year = $3;
45                            $all_titles->{$2}++;
46                            $all_years->{$3}++;
47                  } else {                  } else {
48                          $year = undef;                          $year = undef;
49                  }                  }
# Line 74  while(<$t>) { Line 79  while(<$t>) {
79                  print "#$_\n";                  print "#$_\n";
80          }          }
81    
82    #       last if ($i > 1000);    # XXX remove this!
83    }
84    
85    sub dump_data($$) {
86            my ($name,$hash) = @_;
87    
88            open(my $fh, "> $name") || die "can't open $name: $!";
89    
90            foreach my $k (sort keys %{$hash}) {
91                    print $fh "$k\t",$hash->{$k},"\n";
92            }
93    
94            close($fh);
95  }  }
96    
97    dump_data('titles.data', $all_titles);
98    dump_data('quotes.data', $all_quotes);
99    dump_data('years.data', $all_years);

Legend:
Removed from v.20  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26