SPUG: Modules - more than one object in file?
Todd Wells
toddw at wrq.com
Wed Oct 11 10:26:41 CDT 2000
I'm creating a module which uses some other objects internally, so I have
multiple package statements in the same .pm file to define these other
objects. Is there a good reason why I shouldn't do this? I'd prefer to
keep it all in one file. However, I'm having a problem which I think is
related.
I have my module all in one file that contains 3 package statements, for
objects A, B and C. e.g.:
package A;
sub new { blah }
sub log { fooblah }
1;
package B;
@ISA = sq ( A );
sub new { blahblah }
1;
package C;
sub new { moblah }
1;
However, when I call
$pack_b = B->new();
$pack_b->log("foobar"), I get:
Can't locate package "A" for @B::ISA at A.pm line 274.
Can't locate package "A" for @B::ISA at A.pm line 274.
Can't locate object method "log" via package "B" at A.pm line 274.
Can't locate package "A" for @B::ISA.
At the moment, my package "A" is just A.pm sitting in the same directory as
the program which calls it.
Is there a way to make this work or am I forced to put objects A, B and C in
separate files?
-Todd
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list