Caillte has asked for the wisdom of the Perl Monks concerning the following question:

A bit of a puzzler, this one. I wish to use some OO code that I developed in linux on windows 2000 professional running activestate perl 5.6 build 620. When I moved it over though I found that child objects appeared not to be inheriting subs from their parents. An example that works on Red Hat Linux but will not on Win32 is given below.

Below is the code:

The parent object, stored in Base.pm

#The base object, Base.pm package Base; sub new { my $class = shift; my $self = {}; $class = ref($class) || $class; bless $self, $class; return $self; } 1; # The child object - qwe.html package qwe; use Base; @ISA = ("Base"); 1; # A test program #!/usr/bin/perl -w use qwe; my $x = new qwe();

When run on Win2000 perl returns the error Can't locate object method "new" via package "qwe" at test.pl line 6. Has anyone else run into this problem?

$japh->{'Caillte'} = $me;

Replies are listed 'Best First'.
(tye)Re: OO Inheritance in Win32
by tye (Sage) on Feb 28, 2001 at 21:45 UTC

    Win32 file systems ignore case and there is already a "base.pm" so creating a "Base.pm" is probably not a good idea and might explain your problem.

    Rename things and try again. Let us know.

            - tye (but my friends call me "Tye")

      Please see my previous statement about the legth of the day ;)

      Renamed Base to Foo and checked for the fooness of other packages (surprisingly there was none ;)). Still get the same error.

      $japh->{'Caillte'} = $me;

        I suspect you didn't change all of the cases of "Base" to "Foo" (or you now have both cases of "qwe" and "Qwe"). It didn't work for me on the first try but I had neglected to change "package Base" to "package Foo". Once I changed the last "Base", it worked.

        Please double check your work.

                - tye (but my friends call me "Tye")
Re: OO Inheritance in Win32
by merlyn (Sage) on Feb 28, 2001 at 21:32 UTC
    Did you put it in qwe.html (as the comment indicates) or qwe.pm?

    Also, user-defined packages must begin with an uppercase character to ensure non-collision with pragmas. And I'd recommend a "house prefix" to ensure non-collision with CPAN modules. I use Stonehenge:: or My:: in front of my local modules.

    -- Randal L. Schwartz, Perl hacker

      *grin* been working too long today... was qwe.pm. Unfortunately renaming the package to Qwe and the file to Qwe.pm made no difference.

      $japh->{'Caillte'} = $me;