Mixing subclasses
am 30.12.2006 00:39:47 von brankin
Hello,
Quick question: I am using module Net::FTP::Recursive successfully,
however am having problems when the ftp server terminates a connection.
Note that a different module, Net::FTP::AutoReconnect, has a reconnect
feature to re-establish dropped ftp connections. These two modules were
written by different authors.
Because both modules are subclassses of Net::FTP, is it possible to use
them both? i.e. use Net::FTP::Recursive along with
Net::FTP::AutoReconnect , so the Recursive module has the AutoReconnect
capability? If so, what is the Perl syntax to make this happen in a
script?
Thanks, Brian
Re: Mixing subclasses
am 30.12.2006 13:42:12 von Paul Lalli
brankin@enbonline.net wrote:
> Quick question: I am using module Net::FTP::Recursive successfully,
> however am having problems when the ftp server terminates a connection.
> Note that a different module, Net::FTP::AutoReconnect, has a reconnect
> feature to re-establish dropped ftp connections. These two modules were
> written by different authors.
>
> Because both modules are subclassses of Net::FTP, is it possible to use
> them both? i.e. use Net::FTP::Recursive along with
> Net::FTP::AutoReconnect , so the Recursive module has the AutoReconnect
> capability? If so, what is the Perl syntax to make this happen in a
> script?
>From a quick examination of the sources of the two modules, it *may* be
possible to create a class which inherits from both of these classes.
If you can manage to do that, you could then create an object of your
new class and use that to connect.
Net::FTP::Recursive creates five new methods: rget, rput, rls, rdir,
and rdelete. Net::FTP::AutoReconnect does its work by creating new
methods with the same name as the Net::FTP methods, and wrapping them
in its own _autoreconnect() subroutine. From what I can tell, you
would have to create a class that inherits from both classes, and
redefines Net::FTP::Recursive's five methods the way
Net::FTP::AutoReconnect redefines Net::FTP's.
You would also have to implement a constructor that does the
functionality of both modules' new() methods.
While none of this is exactly trivial, I think it should be possible.
To get you started, you need to read up on classes and inheritance.
Read thoroughly:
perldoc perltoot
perldoc perlmod
perldoc perlmodlib
The basic syntax you'll want to start your new class will look
something like this:
package Net::FTP::RecAutoRec;
use strict;
use warnings;
use Net::FTP::AutoReconnect;
use Net::FTP::Recursive;
our @ISA = qw(Net::FTP::AutoReconnect Net::FTP::Recursive);
Hope this helps,
Paul Lalli
Re: Mixing subclasses
am 10.01.2007 16:28:48 von Craig Manley
Check the Sex module, e.g.:
use Sex qw(LWP::Simple Net::NNTP);
It may do what you want.
schreef in bericht
news:1167435587.669359.214070@73g2000cwn.googlegroups.com...
> Hello,
>
> Quick question: I am using module Net::FTP::Recursive successfully,
> however am having problems when the ftp server terminates a connection.
> Note that a different module, Net::FTP::AutoReconnect, has a reconnect
> feature to re-establish dropped ftp connections. These two modules were
> written by different authors.
>
> Because both modules are subclassses of Net::FTP, is it possible to use
> them both? i.e. use Net::FTP::Recursive along with
> Net::FTP::AutoReconnect , so the Recursive module has the AutoReconnect
> capability? If so, what is the Perl syntax to make this happen in a
> script?
>
> Thanks, Brian
>