in reply to Extend a module
and the the modules MyModule.pm#! /usr/bin/perl use warnings ; use MyModel ; use newModel ; my $m = MyModel->new() ; Class::Trait->apply( $m, newModel ) ; # polymorphic stuff here :) $m->test() ; $m->newTest() ;
and newModel.pm:package MyModel ; sub test { print "MyModel\n" ; } sub new { return bless {}, __PACKAGE__ ; } return 1 ;
Maybe not a very good example, but in your case you can replace MyModule (I think) with Net::FTP, this way you should be able to add new or replace existing subs in Net::FTPpackage newModel ; use Class::Trait 'base' ; sub test { print "add test\n" ; } sub newTest { print "add new test\n" ; } return 1 ;
|
|---|