the_slycer has asked for the wisdom of the Perl Monks concerning the following question:
Which seems to work fine, however, calling a $ftp->ls() on the returned object does not quite do what I need, I get an error stating Not a GLOB reference at /usr/lib/perl5/site_perl/5.6.0/Net/FTP.pm line 905. Looking into the Net::FTP module, I can see why this is happening, the module is being called with a class of Custom::FTP rather than Net::FTP, which means that the variable passed in as the "object" is the Custom::FTP object rather than the parent object.. and the GLOB on line 905 is accessing an undef'd value.package Custom::FTP; use Net::FTP; @ISA = ('Net::FTP'); #proxy module for Net::FTP - allows us to change hostname etc for test +ing purposes sub new { my $class = shift; my $self = {}; bless $self, $class; my $remote_host = shift; #check to see where we are if ( _not_prod() ) { $remote_host = 'our.test.host'; } $self->{parent} = Net::FTP->new($remote_host, @_); return $self; } sub login { my $self = shift; my @opts = @_; if ( _not_prod() ) { $opts[0] = 'testuser'; $opts[1] = 'testpassword'; } my $parent = $self->{parent}; return $parent->login(@opts); } sub _not_prod { #more code }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inheritance confusion
by BrowserUk (Patriarch) on May 20, 2005 at 16:23 UTC | |
by Thelonious (Scribe) on May 23, 2005 at 13:23 UTC | |
|
Re: Inheritance confusion
by holli (Abbot) on May 20, 2005 at 16:09 UTC | |
|
Re: Inheritance confusion
by Fletch (Bishop) on May 20, 2005 at 17:09 UTC | |
|
Re: Inheritance confusion
by chromatic (Archbishop) on May 20, 2005 at 19:29 UTC | |
|
Re: Inheritance confusion
by splinky (Hermit) on May 20, 2005 at 19:01 UTC | |
by revdiablo (Prior) on May 25, 2005 at 17:19 UTC | |
|
Re: Inheritance confusion
by cowboy (Friar) on May 20, 2005 at 22:34 UTC | |
by the_slycer (Chaplain) on May 21, 2005 at 02:00 UTC | |
|
Re: Inheritance confusion
by Anonymous Monk on May 20, 2005 at 20:39 UTC | |
|
Re: Inheritance confusion
by Thelonious (Scribe) on May 23, 2005 at 13:07 UTC | |
by GoCool (Scribe) on May 25, 2005 at 16:35 UTC |