Subversion Repositories wimsdev

Rev

Rev 11480 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/perl
  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. ####
  9. print "prepare taxonomy files ...";
  10. for my $f (glob("src/*")) {
  11.   my $f0=$f ; $f0 =~ s/src\///;
  12.   dicclassification ($f0, ($f));
  13. }
  14.  
  15. my $prelim="##This file is generated by classif.pl. Do not modify directly\n";
  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 ; } else { $ref{$a} = $t ; }
  40.       }
  41.     }
  42.     close IN;
  43.   }
  44.   %ref
  45. }
  46.  
  47. sub out { my ($bloc, $text) = @_;
  48.   open  (OUT, ">$bloc") ;
  49.   print OUT $text ; close OUT;
  50. }
  51.