My, my my. Overload, wrapped in a tie, wrapped in an attribute. That doesn't make debugging easier. If you have trouble with such a setup, you need to peel back the various layers and test each one separately, first overloading, then the tie interface, then the attribute wrapper.

I wonder whether there is a way to overload the ++ operator or not.

The increment operator *is* overloaded as systematic testing shows. The problem is that the TieStringifiableInteger::STORE method is called with the stringified version of the new value instead of the numeric one. (No, I don't know offhand why that happens.) Change it to

sub STORE { my ($self, $value) = @_; $$self->set(0 + $value); }
That forces the numeric value and fixes the error.

As a side note, is there a reason why two of the overloading functions ('""' and '0+') are named methods but '++' is implemented anonymously?

What is your opinion on such a module? Is it worth uploading to CPAN? A note; I am designing to module to add stringification for different languages.

In my view, the module has an overly involved interface to call a function automatically that would better be called explicitly from case to case. The basic function (converting numbers to strings) is already covered by CPAN modules for various langiages, including Turkish (Lingua::TR::Numbers)

Anno


In reply to Re: Cannot overload ++ when the object is accessed via Attribute -> Tie -> Class by Anno
in thread Cannot overload ++ when the object is accessed via Attribute -> Tie -> Class by mayaTheCat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.