in reply to Simple OO

If this code fragment is really in a single file, then you don't need   use sheep; Since the 'sheep' package is already in the symbol table. use is a bit confusing that way. The argument refers to a file, not a package. You have to trust that the file being use'd actually defines a package of the same name.

Replies are listed 'Best First'.
Re: Re: Simple OO
by lzcd (Pilgrim) on Feb 12, 2002 at 06:59 UTC
    Without the use statement I get:
    No such class wolf at demo.pl line 22, near "my wolf" syntax error at demo.pl line 22, near "my wolf="

      You're missing some $'s ...

      my $wolf=new sheep;
      print $wolf->bleet()."\n";

          --k.


        This, and you need ref($proto) not ref{$proto} (parentheses not braces).

      Without the use statement I get:
      No such class wolf at demo.pl line 22, near "my wolf" syntax error at demo.pl line 22, near "my wolf="
      The reason for this error message is a bit more obscure. (It has to do with something called "indirect object syntax".) However, the error goes away if turn the bareword wolf into the scalar $wolf.
      my $wolf=new sheep; ^
      I suspect this is what you had in mind.

        Obviously my brain is feeling unpunctuated today. Thank you all for the $help. Sorry to be a pain but any ideas on why I get a
        Can't locate object method "bleet" via package "HASH" at demo.pl line +23.
        ? (Is this my cargo finally coming home?)