NAME
Net::MirrorDir - Perl extension for compare local-directories and remote-directories with each other
SYNOPSIS
 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();
DESCRIPTION
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.
Constructor and Initialization
required optines
- ftpserver the hostname of the ftp-server
 - user the username for authentification
 - pass password for authentification
 
optional optiones
- localdir local directory default = '.'
 - remotedir remote location default '/'
 - debug Set it to a true value (1 'yes' 'ok') for information about the ftp-process, or false (0 '') to avoid debug output. default 1
 - timeout the timeout for the ftp-serverconnection, default 30
 - connection (class-attribute) takes a Net::FTP-object, you should not create the object by yourself, instead of this call the Connect(); function to set the connection. default undef
 - exclusions takes a reference to a array of strings interpreted as regular-expressios matching to something in the local or remote pathnames, pathnames matching will be ignored You can also use a regex object [qr/PASS/i, $regex, "system"] default []
 - subset takes a reference to a list of strings interpreted as regular-expressios matching to something in the local or remote pathnames, pathnames NOT matching will be ignored. You can also use a regex object [qr/TXT/i, "name", qr/MY_FILES/i, $regex] default empty list [ ]
 
methods
- (ref_hash_local_files, ref_hash_local_dirs)object->ReadLocalDir(void) =item (ref_hash_local_files, ref_hash_local_dirs)object->ReadLocalDir(path) The directory, indicated with the attribute "localdir" or directly as parameter, is searched. Returns two hashreferences first the local-files, second the local-directorys. The values are in the keys. You can also call the functions: (ref_hash_local_dirs)object->GetLocalDirs(void) (ref_hash_local_files)object->GetLocalFiles(void) in order to receive the results. If ReadLocalDir() fails, it returns references to empty hashs.
 - (ref_hash_remote_files, ref_hash_remote_dirs)object->ReadRemoteDir(void) =item (ref_hash_remote_files, ref_hash_remote_dirs)object->ReadRemoteDir(path) The directory, inidcated with the attribute "remotedir" or directly as parameter, is searched. Returns two hashreferences first the remote-files, second the remote-directorys. The values are in the keys. You can also call the functions: (ref_hash_remote_files)object->GetRemoteFiles(void) (ref_hash_remote_dirs)object->GetRemoteDirs(void) in order to receive the results. If ReadRemoteDir() fails, it returns references to empty hashs.
 - (1|0)object->Connect(void) Makes the connection to the ftp-server. Uses the attributes "ftpserver", "usr" and "pass".
 - (1)object->Quit(void) Closes the connection with the ftp-server.
 - (ref_list_paths_not_in_remote)object->LocalNotInRemote( ref_hash_local_paths, ref_hash_remote_paths ) Takes two hashreferences, first the localpaths, second the remotepaths, to compare with each other. Returns a reference of a list with files or directorys found in the local directory but not in the remote location.
 - (ref_list_paths_not_in_local)object->RemoteNotInLocal( ref_hash_local_paths, ref_hash_remote_paths ) Takes two hashreferences, first the localpaths, second the remotepaths, to compare with each other. Returns a reference of a list with files or directorys found in the remote location but not in the local directory.
 - (value)object->get_option(void) =item (1)object->set_option(value) The functions are generated by AUTOLOAD, for all options. The syntax is not case-sensitive and the character '_' is optional.
 - (1) object->add_option(value) The functions are generated by AUTOLOAD, for arrayrefrences options. Like "subset" or "exclusions" The syntax is not case-sensitive and the character '_' is optional.
 - (0) _Init(void) Abstract method should be defined in every derived class.
 
EXPORT
None by default.
SEE ALSO
Net::UploadMirror Net::DownloadMirror Net::FTP http://www.freenet-homepage.de/torstenknorr
FILES
Net::FTP
BUGS
Maybe you'll find some. Let me know.
REPORTING BUGS
When reporting bugs/problems please include as much information as possible.
AUTHOR
Torsten Knorr, <create-soft@freenet.de>
COPYRIGHT AND LICENSE
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.
8 POD Errors
The following errors were encountered while parsing the POD:
- Around line 433:
 '=item' outside of any '=over'
- Around line 435:
 You forgot a '=back' before '=head2'
- Around line 437:
 '=item' outside of any '=over'
- Around line 446:
 You forgot a '=back' before '=head2'
- Around line 448:
 '=item' outside of any '=over'
- Around line 483:
 You forgot a '=back' before '=head2'
- Around line 485:
 '=item' outside of any '=over'
- Around line 543:
 You forgot a '=back' before '=head2'