http://qs321.pair.com?node_id=650448


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