I would do something like this:
use strict; # very important, and saves a lot of headache!
open (SERV, "c:\\perl\\bin\\liste.txt") || die "Could not open liste.txt:
$!"; # added error checking
my @serveurs = <SERV>;
close (SERV);
open (RESULT, ">>c:\\resultat.txt") || die "Could not open resultat.txt:
$!"; # added error checking;
foreach my $ligne (@serveurs)
{
my @fichiers =
(
"\\\\$ligne\\f\$\\cmd\\active.vbs",
"\\\\$ligne\\f\$\\universe\\data\\exp\\upr\\upe_dsms.000",
"\\\\$ligne\\f\$\\universe\\data\\exp\\upr\\upe_psms.000",
"\\\\$ligne\\g\$\\common\\bin\\upecbootnt.cmd",
);
# this loop does exactly what you were doing before, but is a little less
verbose, and easier to maintain.
#Remember, when you catch yourself copying and pasting code, it's probably
time for a loop or a function.
#I've taken the four files that you want to check, and stuck them in the
array above.
#Now we'll loop through the array and check each file.
#Want to check another file in the future? Add it to the array, and
you're done!
foreach my $fichier (@fichiers)
{
my $result = (-e $fichier)? "$fichier fait (stat $fichier)[7]
octets\n" :
"$fichier inexistant \n";
print RESULT $result;
}
}
close RESULT;
Aaron Craig
Programming
iSoftitler.com