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",
	usr		=> "my_ftp_usr_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_new_remote_files = $md->RemoteNotInLocal($ref_h_local_files, $ref_h_remote_files);
my $ref_a_new_local_files = $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",
	usr		=> "my_ftp_usr_name",
	pass		=> "my_ftp_password",
	localdir		=> "home/nameA/homepageA",
	remotedir	=> "public",
	debug		=> 1 # 1 for yes, 0 for no
	timeout		=> 60 # default 30
	delete		=> "enable" # default "disabled"
	connection	=> $ftp_object, # default undef
# "exclusions" default empty arrayreferences [ ]
	exclusions	=> ["private.txt", "Thumbs.db", ".sys", ".log"],
# "subset" default empty arrayreferences [ ]
	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
	exclusinos	=> [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_new_local_files = $md->LocalNotInRemote($ref_h_local_files, $ref_h_remote_files);
if($md->{_debug})
	{
	print("new local files : $_\n") for(@{$ref_a_new_local_files});
	}
my $ref_a_new_local_dirs = $md->LocalNotInRemote($ref_h_local_dirs, $ref_h_remote_dirs);
if($md->{_debug})
	{
	print("new local dirs : $_\n") for(@{$ref_a_new_local_dirs});
	}
my $ref_a_new_remote_files = $md->RemoteNotInLocal($ref_h_local_files, $ref_h_remote_files);
if($md->{_debug})
	{
	print("new remote files : $_\n") for(@{$ref_a_new_remote_files});
	}
my $ref_a_new_remote_dirs = $md->RemoteNotInLocal($ref_h_local_dirs, $ref_h_remote_dirs);
if($md->{_debug})
	{
	print("new remote dirs : $_\n") for(@{$ref_a_new_remote_dirs});
	}
$md->Quit();

DESCRIPTION

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

Constructor and Initialization

(object) new (options)

required optines

ftpserver the hostname of the ftp-server
usr the username for authentification
pass password for authentification

optional optiones

localdir local directory selecting information from, default '.'
remotedir remote location selecting information from, default '/'
debug set it true for more information about the ftp-process, default 1
timeout the timeout for the ftp-serverconnection
delete this attribute is used in the child-class Net::UploadMirror and Net::DownloadMirror, default "disabled"
connection takes a Net::FTP-object you should not use that, instead of this call the Connect(); function to set the connection. Following functions of the used FTP-object should be identical to the Net::FTP-object functions. cwd(path), size(file), mdtm(file), ls(path), default undef
exclusions a reference to a list of strings interpreted as regular-expressios ("regex") matching to something in the local or remote pathnames, you do not want to list, You can also use a regex direct [qr/PASS/i, $regex, "system"] default empty list [ ]
subset a reference to a list of strings interpreted as regular-expressios ("regex") matching to something in the local or remote pathnames, pathnames NOT containing the string will be ignored. You can also use a regex direct [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) =item (void) object->ReadLocalDir (path) Returns two hashreferences first the local-files, second the local-directorys found in the directory given by the MirrorDir-object, (uses the attribute "localdir") or given directly as parameter. The values are in the keys. You can also call the functions (ref_hash_local_dirs) object->GetLocalDirs() (ref_hash_local_files) object->GetLocalFiles() in order to receive the results. If ReadLocalDir() fails, it returns hashreferences 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) =item (void) object->ReadRemoteDir (path) Returns two hashreferences first the remote-files, second the remote-directorys found in the directory given by the MirrorDir-object, (uses the attribute "remotedir") or given directly as parameter. The values are in the keys. You can also call the functions (ref_hash_remote_files) object->GetRemoteFiles() (ref_hash_remote_dirs) object->GetRemoteDirs() in order to receive the results. If ReadRemoteDir() fails, it returns hashreferences to empty hashs.
(1) object->Connect (void) Makes the connection to the ftp-server. Uses the attributes "ftpserver", "usr" and "pass" given by the MirrorDir-object.
(1) object->Quit (void) Closes the connection with the ftp-server.
(ref_hash_local_paths, ref_hash_remote_paths) object->LocalNotInRemote (ref_list_new_paths) Takes two hashreferences, given by the functions ReadLocalDir(); and ReadRemoteDir(); 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. Uses the attribute "localdir" and "remotedir" given by the MirrorDir-object.
(ref_hash_local_paths, ref_hash_remote_paths) object->RemoteNotInLocal (ref_list_deleted_paths) Takes two hashreferences, given by the functions ReadLocalDir(); and ReadRemoteDir(); 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. Uses of the attribure "localdir" and "remotedir" given by the MirrorDir-object.
(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.

EXPORT

None by default.

SEE ALSO

Net::UploadMirror Net::DownloadMirror Net::FTP http://www.planet-interkom.de/t.knorr/index.html

FILES

Net::FTP

BUGS

Maybe you'll find some. Let me know.

AUTHOR

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

COPYRIGHT AND LICENSE

Copyright (C) 2006 - 2008 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 360:

'=item' outside of any '=over'

Around line 362:

You forgot a '=back' before '=head2'

Around line 364:

'=item' outside of any '=over'

Around line 373:

You forgot a '=back' before '=head2'

Around line 375:

'=item' outside of any '=over'

Around line 415:

You forgot a '=back' before '=head2'

Around line 417:

'=item' outside of any '=over'

Around line 470:

You forgot a '=back' before '=head2'