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 43
| ##########inclusion
sub imprime_fichier {
my $fichier = shift;
print $fichier, "\n";
$ftp->put($fichier);
}
my $code_ref = \&imprime_fichier; # crée une référence sur la fonction
sub parcours_dir {
my ($code_ref, $path) = @_;
my @dir_entries = glob("$path/*");
foreach my $entry (@dir_entries) {
$code_ref->($entry) if -f $entry;
#ici je ne veux pas de la recursivité pour l'instant (trop compliqué à gerer rapidement)
# parcours_dir($code_ref, $entry) if -d $entry;
}
}
#fin inclusion
#article
$ftp->cwd($pub_articles)
or die sprintf "je ne peux aller dans pub_articles: %s", $ftp->message;
my $dir_depart = $articles;
parcours_dir($code_ref, $dir_depart);
print $ftp->ls;
sleep 3;
$ftp->cdup( )
or die sprintf "je ne peux retourner à pub: %s", $ftp->message;
print $ftp->pwd( );
#fin article |
Partager