Subversion Repositories wimsdev

Rev

Rev 11479 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11480 schaersvoo 1
#!/usr/bin/perl
7708 bpr 2
 
3
use warnings;
4
use strict;
5
use Encode qw(encode decode);
6
#### for an identifier in a taxo, make the list of the modules
7
#### which refers to this identifier
8
####
8946 bpr 9
print "prepare taxonomy files ...";
7716 bpr 10
for my $f (glob("src/*")) {
11
  my $f0=$f ; $f0 =~ s/src\///;
12
  dicclassification ($f0, ($f));
7712 bpr 13
}
14
 
7880 bpr 15
my $prelim="##This file is generated by classif.pl. Do not modify directly\n";
7708 bpr 16
sub  dicclassification { my ($dirout, @liste)=@_;
17
  my %ref=reverse_dic(@liste);
18
  my $TEXT=$prelim;
19
  for my $k (sort keys %ref) {
20
   if ($ref{$k}) {
21
    $TEXT .= "$k:$ref{$k}\n";
22
   }
23
  out("$dirout", $TEXT);
24
  }
25
}
26
 
27
sub reverse_dic { my @liste=@_;
28
  my %ref = ( ) ; my $ref=\%ref;
29
  for my $file (@liste) {
30
   open IN, "$file";
31
   while (<IN>) {
32
    next if ($_ =~ /^#/);
33
    my $text= $_ ; $text=~ s/\n//;
34
    my @text=split(":", $text);
35
    next if !($text[1]);
36
    my $t=$text[0]; $t=~ s/\n//;
37
    my @L= split(",",$text[1]);
38
    for my $a (@L) {
39
     if ($ref{$a}) {  $ref{$a}.= "," . $t ; }
40
     else { $ref{$a} = $t ; }
41
    }
42
   }
43
   close IN;
44
  }
45
  %ref
46
}
47
 
48
sub out { my ($bloc, $text) = @_;
49
  open  (OUT, ">$bloc") ;
50
  print OUT $text ; close OUT;
51
}