Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: "individually" override a super class's object methods

by Somni (Friar)
on Nov 13, 2007 at 06:53 UTC ( [id://650448]=note: print w/replies, xml ) Need Help??


in reply to "individually" override a super class's object methods

$self->modified = sub { 0 }; produces the error: "Can't modify non-lvalue subroutine call at MyChild.pm line 12"

This is attempting to call the modified() method and treat it as an lvalue, which requires an lvalue attribute on the subroutine declaration.

whereas $self::modified = sub { 0 } has no effect.

This simply assigns an anonymous sub to the scalar $self::modified.

As GrandFather described, you need to provide actual subroutines. I'm not sure where you came up with this random syntax. You might want to read Beginning Perl's Chapter on object-oriented Perl, perlboot, and perltoot.

  • Comment on Re: "individually" override a super class's object methods

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://650448]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-25 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found