#!/usr/bin/perl <:encoding(UTF-8)","corpus-Rss-$rubrique.txt"; open my $output2, ">:encoding(UTF-8)","corpus-Rss-$rubrique.xml"; #----------------------------------------------------------- print $output2 "\n\n"; $file=~ s/[\/]$//; my %dico=(); &parcoursarborescence($file); print $output2 "\n"; close $out; close $output2 ; exit; #--------------------- sub parcoursarborescence { my $path = shift(@_); open (DIR, $path) or die "can't open $path : $!\n"; my @files = readdir(DIR); closedir(DIR); foreach my $file(@files) { next if $file =~/^\.\.?$/; $file=$path."/".$file; if (-d $file) { &parcoursarborescence($file); #recursivité } if (-f $file) { if ($file =~ /\.xml$/ and $file =~ /$rubrique/) { eval {$rss->parsefile($file); }; # on remplit l'objet via parsefile if( $@ ) { $@ =~ s/at \/.*?$//s; # remove module line number print STDERR "\nERROR in '$file':\n$@\n"; } else { foreach my $item (@{$rss->{'items'}}) { my $titre=&nettoyage($item->{'title'}); my $description=&nettoyage($item->{'description'}); if (!(exists $dico{$titre})){ $dico{$titre}=$description; print $out "$titre \n"; print $out "$description \n"; print $out "----------------------------\n"; print $output2 "$titre$description\n"; } } } } } print "---------------------\n"; } } #------------------------------------------------ sub nettoyage { my $texte=shift @_; $texte=~s/(^$)//g; $texte.="."; $texte=~s/\.+$/\./; return $texte; }