Inheritace problem - class can't find parent 
Author Message
 Inheritace problem - class can't find parent

Hi,
   I'm having a real problem getting a class to inherit from another
one - it's says it can't find the parent, but the parent's path is

/share/daisy/www-data/lib/common/ConfigFile.pm - base class
/share/daisy/www-data/lib/SGD/ConfigFileSGD.pm - child class
/share/daisy/www-data/cgi-bin/SGDDEV/test.pl - test program

the content (somwhat abbreviated):

package ConfigFile;

use strict;

####################################################################
sub new{
####################################################################
# This simple constructor initializes a few variables, and returns a
# blessed hash, which can then be used to call the various methods

    my $self = {};

    bless $self, shift;

    return $self;

Quote:
}

1;

#####################################################################

package ConfigFileSGD;

use strict;

# has no constructor, as should inherit from parent



    print $_, "\n";

Quote:
}


    print $_, "\n";

Quote:
}

1; # to keep perl happy

########################################################################

test.pl:

#!/usr/bin/perl -w

use strict;

use lib "/share/daisy/www-data/lib/SGD";
use ConfigFileSGD;

my $config = ConfigFileSGD->new();

########################################################################

The output I then get, when I run test.pl is the following:

/share/daisy/www-data/lib/common
/share/daisy/www-data/lib/SGD
/tools/perl/current/lib
/tools/perl/5.004/lib/perl5/sun4-solaris/5.00404
/tools/perl/5.004/lib/perl5
/tools/perl/5.004/lib/perl5/site_perl/sun4-solaris
/tools/perl/5.004/lib/perl5/site_perl
.
ConfigFile

6.

8.

8.
Can't locate object method "new" via package "ConfigFileSGD" at test.pl
line 8.

Any help on this - tell me if I'm simply being stupid - would be
greatly appreciated,
Cheers,
Gavin



Sun, 02 Mar 2003 01:18:56 GMT  
 Inheritace problem - class can't find parent

Quote:

> package ConfigFileSGD;

> use strict;

> # has no constructor, as should inherit from parent

> use lib "/share/daisy/www-data/lib/common"; # where to find the parent

<snip>
> #!/usr/bin/perl -w

> use strict;

> use lib "/share/daisy/www-data/lib/SGD";
> use ConfigFileSGD;

> my $config = ConfigFileSGD->new();


Typically, the subclass (ConfigFileSGD) is responsible for
use'ing the superclass, but it certainly works for the main
script to do it.


and use ConfigFile in one swell foop.



Sun, 02 Mar 2003 07:58:21 GMT  
 Inheritace problem - class can't find parent

Quote:


> Typically, the subclass (ConfigFileSGD) is responsible for
> use'ing the superclass, but it certainly works for the main
> script to do it.

This answer is essentially correct, but it is not correct to
say that "it certainly works for the main script to do it",
if the use'd module exports any symbols.
(An OO module shouldn't export symbols anyway; but if it does,
one must follow the module's instructions on where and how to
use it.)

--
John Porter

        We're building the house of the future together.



Sun, 02 Mar 2003 11:17:38 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Comparing 2 dbase filesd

2. Grid Width and mandatory field exception

3. Help: using constants from inherited parent class

4. Using Tk::MainWindow as a parent class...

5. child's output corrupted by parent's output

6. Classes and Collections of Classes - PROBLEM

7. Find parent nodes in a hash

8. Create field in SQL - any ideas?

9. Need program to list all directories and the number of members i

10. Setting parent's environment variables

11. Getting parent process's environment variable to change when running a perl script

12. Q: How to have child process change var's in parent

 

 
Powered by phpBB® Forum Software