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

shemp has asked for the wisdom of the Perl Monks concerning the following question:

I was wondering if there is any way built-in to Class::Struct generated objects that would allow incrementing (and decrementing) in an overloaded sort of way, as opposed to building my own operator overloads. What i mean is, i'd like to be able to do something like:
use strict; use warnings; use Class::Struct; struct MyStruct => { 'Counter' => '$', ... } my $x = MyStruct('Counter', 0); $x->Counter++; # of course i could always do the following: $x->Counter( $x->Counter + 1 );
Is what i want to do directly possible (built-in)? I suppose i'd also like to be able to:
... $x->Counter += 7;
will i need to build my own overloads?