dragonchild,
Well, to know for sure I would need to see the TIEARRAY sub from My::Class, but I think you are misreading tie. The new() function for a tied class is replaced by "TIESCALAR", "TIEHANDLE", "TIEARRAY", or "TIEHASH".

As for why it is returning a blessed reference - that's what it supposed to do. That is so you can create a hybrid OO and tied object to do things like:

my $obj = tie my @array, 'My::Class'; $obj->some_method;
The uglier way to do that without storing the return value is to do:
(tied @array)->some_method();
It is important to note that you should undef $obj before trying to untie @array. Ultimately the underlying object needn't be the same type as the user sees. If you look under the covers of my Tie::Hash::Sorted, you will see that the hash is really an array under the covers.

If you want to post more code of My::Class I would be happy to take a look.

Cheers - L~R


In reply to Re: The return value of tie() by Limbic~Region
in thread The return value of tie() by dragonchild

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.