Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by Somni (Friar)
on Nov 13, 2007 at 06:53 UTC ( #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 imbibing at the Monastery: (4)
As of 2023-12-10 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?