1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#!/usr/bin/perl
use strict ;
my @Fichiers_Tous; #On a tous les fichiers du repertoire courant
my @Fichiers_PL_PM; #On a un tableau contenant les fichiers PL et PM
my $Fichier_Courant;#On a le fichier courant
my $Ligne_Fichier_Courant;
###########################
my @tata;
my $Nouveau_chemin="use lib '/toto/tata'";
opendir Repertoire, "." or die "$!\n"; #Ouverture du repertoire courant grace au point "."
@Fichiers_Tous = readdir Repertoire; #Ici on place tous les fichiers dans le tableau @Fichiers_Tous
for $Fichier_Courant (@Fichiers_Tous )#On parcours le tableau @Fichiers_Tous
#et l on place ligne par ligne dans $Fichier_Courant
{
next if $Fichier_Courant eq "." or $Fichier_Courant eq "..";#On zappe cees deux repertoires speciaux
if($Fichier_Courant=~/\.pl$/ or $Fichier_Courant=~/\.pm$/) #On selectionne que les fichiers PM et PL
{
push(@Fichiers_PL_PM, $Fichier_Courant); #On place les fichier trouves pl
#et pm dans le tableau @Fichiers_PL_PM
}
}
print "\n";
#On parcours ligne par ligne le tableau contenant les fichiers pm et pl
foreach $Fichier_Courant (@Fichiers_PL_PM)
{
print "###$Fichier_Courant###\n";
##Cas pour le chemin des librairies on va remplacer
open(Fichier_courant,$Fichier_Courant)|| die ("Problemes de fichiers:\n $! ");
print"\n###$Fichier_Courant###\n";
while ($Ligne_Fichier_Courant = <Fichier_courant> )
{
print"\n##$Ligne_Fichier_Courant\n##";
@tata =s/use/$Nouveau_chemin/;
#print"## @tata ##";
}
print"## @tata ##";
close Fichier_courant;
} |