Click here to get back home

Mixing subclasses

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Mixing subclasses brankin 12-29-2006
Posted by brankin on December 29, 2006, 6:39 pm
Please log in for more thread options


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


Posted by Paul Lalli on December 30, 2006, 7:42 am
Please log in for more thread options


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


Posted by Craig Manley on January 10, 2007, 10:28 am
Please log in for more thread options


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

> 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
>



Similar ThreadsPosted
Mixing HTML::Template and GD::Graph May 14, 2005, 8:53 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap