develooper Front page | perl.perl5.porters | Postings from November 2003

Re: Cwd::cwd() bug??? on Cygwin

Thread Previous | Thread Next
Nick Ing-Simmons
November 21, 2003 13:02
Re: Cwd::cwd() bug??? on Cygwin
Message ID:
Nick Ing-Simmons <> writes:
>>> package MyModule;
>>> use Module;
>>> use base 'Module';
>>> use Cwd;
>If you moved that above the use Module line then when 
>was compiled it would know Cwd::cwd was a function.

Sorry I could not see wood for the trees!

What is happening is that in MyModule you 'use Cwd',
which EXPORTS 'cwd' by default - so now there is a MyModule::cwd
which is a legitimate over-ride of base class's version so...

You call MyModule->new which inherits from Module->new - so far so good.
But then Module::new calls MyModule->cwd which is the imported one.
So fix is: 

package MyModule;
use Module;
use base 'Module';
use Cwd ();    # No imports!

Alternatively Module's new could do 

sub new {
   my $p = shift;
   Module->cwd;  # ignore override by derived class.   

But that rather spoils it as a base class.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About