Utilisateur:Kipmaster/xml extract wikilien.pl

#!/usr/bin/perl


$intext = 0 ;
$titlebien = 0 ;

while (<>) {

   $ligne = $_ ;
   $ligne_cp = $ligne ;
   while ( $ligne =~ /\[\[(.*?)\]\](.*)/ ) {
     $mot = $1 ;
     $ligne = $2 ;
     if ( $mot =~ /.*[:|\#].*/ ) {
 	# il y a ":" ou "#" dans le mot, on jarte
     } else {
       if ( $mot =~ /(.*?)\|.*/ ) {
         $mot = $1 ;
       }
       print "$1\n" ;
     } # else : le mot contient pas :
   }

  # pareil pour les traductions
  $ligne = $ligne_cp ;
  while ( $ligne =~ /\{\{trad\|[^\|]+?\|(.*?)\}\}(.*)/ ) {
    $mot = $1 ;
    $ligne = $2 ;
    if ( $mot =~ /.*[:|\#].*/ ) {
	# il y a ":" ou "#" dans le mot, on jarte
    } else {
      if ( $mot =~ /(.*?)\|.*/ ) {
        $mot = $1 ;
      }
      print "$1\n" ;
    } # else : le mot contient pas :
  }

}