Mixing subclasses

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


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

Thanks, Brian

Re: Mixing subclasses

brankin@enbonline.net wrote:
Quoted text here. Click to load it

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

Check the Sex module, e.g.:
use Sex qw(LWP::Simple Net::NNTP);
It may do what you want.

Quoted text here. Click to load it

Site Timeline