Avox has asked for the wisdom of the Perl Monks concerning the following question:
When I run test.pl, I get this error: Can't locate object method "new" via package "cat" (perhaps you forgot to load "cat"?) at test.pl line 3. I hope I'm just doing something stupid. Thanks all!-----test.pl------- use Cat; $mycat = cat->new(); $mycat->feed("fish"); exit; -----Cat.pm------- package Cat; use strict; use warnings; our $VERSION = '0.01'; our @ISA = (); sub new { my $class = shift; my $self = { Stomach => "empty" }; bless $self, $class; return $self; } sub feed { my ( $self, $food ) = @_; $self->{ Stomach } = $food if defined $food; return $food; } 1; __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: creating class base modules
by Fletch (Bishop) on Dec 17, 2002 at 15:47 UTC | |
|
Re: creating class base modules
by adrianh (Chancellor) on Dec 17, 2002 at 15:48 UTC | |
by Aristotle (Chancellor) on Dec 17, 2002 at 16:00 UTC | |
|
Re: creating class base modules
by stephen (Priest) on Dec 17, 2002 at 15:49 UTC | |
|
Re: creating class base modules
by Avox (Sexton) on Dec 17, 2002 at 15:57 UTC | |
|
Re: creating class base modules
by aging acolyte (Pilgrim) on Dec 17, 2002 at 16:17 UTC | |
by pfaut (Priest) on Dec 17, 2002 at 16:27 UTC |