
Net::MirrorDir - Perl extension for compare local-directories and remote-directories with each other

use Net::MirrorDir;
my $md = Net::MirrorDir->new(
ftpserver => "my_ftp.hostname.com",
user => "my_ftp_user_name",
pass => "my_ftp_password",
);
my ($ref_h_local_files, $ref_h_local_dirs) = $md->ReadLocalDir();
my ($ref_h_remote_files, $ref_h_remote_dirs) = $md->ReadRemoteDir();
my $ref_a_remote_files_not_in_local = $md->RemoteNotInLocal(
$ref_h_local_files,
$ref_h_remote_files
);
my $ref_a_local_files_not_in_remote = $md->LocalNotInRemote(
$ref_h_local_files,
$ref_h_remote_files
);
$md->Quit();
or more detailed
my $md = Net::MirrorDir->new(
ftpserver => "my_ftp.hostname.com",
user => "my_ftp_user_name",
pass => "my_ftp_password",
localdir => "home/nameA/homepageA",
remotedir => "public",
debug => 1 # 1 for yes, 0 for no
timeout => 60 # default 30
connection => $ftp_object, # default undef
# "exclusions" default references to a empty array []
exclusions => ["private.txt", "Thumbs.db", ".sys", ".log"],
# "subset" default references to a empty array []
subset => [".txt, ".pl", ".html", "htm", ".gif", ".jpg", ".css", ".js", ".png"]
# or substrings in pathnames
# exclusions => ["psw", "forbidden_code"]
# subset => ["name", "my_files"]
# or you can use regular expressions
# exclusions => [qr/SYSTEM/i, $regex]
# subset => [qr/(?i:HOME)(?i:PAGE)?/, $regex]
);
$md->SetLocalDir("home/name/homepage");
print("hostname : ", $md->get_ftpserver(), "\n");
$md->Connect();
my ($ref_h_local_files, $ref_h_local_dirs) = $md->ReadLocalDir();
if($md->{_debug})
{
print("local files : $_\n") for(sort keys %{$ref_h_local_files});
print("local dirs : $_\n") for(sort keys %{$ref_h_local_dirs});
}
my ($ref_h_remote_files, $ref_h_remote_dirs) = $md->ReadRemoteDir();
if($md->{_debug})
{
print("remote files : $_\n") for(sort keys %{$ref_h_remote_files});
print("remote dirs : $_\n") for(sort keys %{$ref_h_remote_dirs});
}
my $ref_a_local_files_not_in_remote = $md->LocalNotInRemote(
$ref_h_local_files,
$ref_h_remote_files
);
if($md->{_debug})
{
print("new local files : $_\n") for(@{$ref_a_local_files_not_in_remote});
}
my $ref_a_local_dirs_not_in_remote = $md->LocalNotInRemote(
$ref_h_local_dirs,
$ref_h_remote_dirs
);
if($md->{_debug})
{
print("new local dirs : $_\n") for(@{$ref_a_local_dirs_not_in_remote});
}
my $ref_a_remote_files_not_in_local = $md->RemoteNotInLocal(
$ref_h_local_files,
$ref_h_remote_files
);
if($md->{_debug})
{
print("new remote files : $_\n") for(@{$ref_a_remote_files_not_in_local});
}
my $ref_a_remote_dirs_not_in_local = $md->RemoteNotInLocal(
$ref_h_local_dirs,
$ref_h_remote_dirs
);
if($md->{_debug})
{
print("new remote dirs : $_\n") for(@{$ref_a_remote_dirs_not_in_local});
}
$md->Quit();

This module is written as base class for Net::UploadMirror and Net::DownloadMirror. However, it can be used, also for themselves alone. It can compare local-directories and remote-directories with each other. To find which files where in which directory available.

None by default.

Net::UploadMirror Net::DownloadMirror Net::FTP http://www.freenet-homepage.de/torstenknorr

Net::FTP

Maybe you'll find some. Let me know.

When reporting bugs/problems please include as much information as possible.

Torsten Knorr, <create-soft@freenet.de>

Copyright (C) 2006 - 2009 by Torsten Knorr
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.9.2 or, at your option, any later version of Perl 5 you may have available.