/[pub]/suikawiki/wikidata/migration/props.pl
Suika

Contents of /suikawiki/wikidata/migration/props.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue May 4 00:56:31 2010 UTC (15 years ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
added to the repository

1 wakaba 1.1 use strict;
2    
3     my $props = {};
4    
5     while (<>) {
6     tr/\x0d\x0a//d;
7     my $file_name = $_;
8     warn $file_name;
9    
10     open my $file, '<', $file_name or die "$0: $file_name: $!";
11    
12     my $last_prop = '';
13    
14     while (<$file>) {
15     tr/\x0d\x0a//d;
16     if (s/^\s+//) {
17     $props->{$last_prop}->{$_}++;
18     } else {
19     my $p = $_;
20     if ($p =~ s/:([^:]+)$//) {
21     my $v = $1;
22     $v =~ s/^\s+//;
23     $props->{$p}->{$v}++;
24     } else {
25     $p =~ s/:\s*$//;
26     }
27     $props->{$last_prop = $p}->{'__prop__'}++;
28     }
29     }
30    
31    
32     }
33    
34     use Data::Dumper;
35     print Dumper ($props);

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24