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

Randy W. Sims RandyS@ThePierianSpring.org
Sat Nov 22 08:57:00 GMT 2003


On 11/21/2003 4:03 PM, Nick Ing-Simmons wrote:
> Nick Ing-Simmons <nick.ing-simmons@elixent.com> writes:
> 
>>>>package MyModule;
>>>>use Module;
>>>>use base 'Module';
>>>>use Cwd;
>>
>>If you moved that above the use Module line then when Module.pm 
>>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.
> 

Ok, both of these work. I see now where I was flawed in understanding 
this one.

Many thanks to Nick, Adi, and Yitzchak (May I ask how to pronounce your 
name?) for the explanations and solutions.

BTW, strictly speaknig, wouldn't this still be considered a bug, since 
the behaviour difers depending on platform.

-- 
A little learning is a dang'rous thing;
Drink deep, or taste not the Pierian spring;
There shallow draughts intoxicate the brain;
And drinking largely sobers us again.
                 - Alexander Pope


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list