Now that looks to me to be an error, if you had an array reference, then leave it alone, if you didn't then try to dereference it as an array reference? If you didn't have an array reference, what possible sense does it make to dereference it as one?

No, the code you're querying is correct. You're missing the fact that the autogenerated handler also has this line in it:

\$data = [ \$data ] unless \$was_arrayref;

So the effect of that code is to pass array refs to tie as array refs, and non-array-refs to tie as lists.

There is a bug here, but it was elsewhere: namely that the codewasn't correctly distinguishing between an attribute with a list of args (:Attr('list','of','args')) and an attribute with a single array ref as an arg (:Attr(['list','of','args'])). I've now fixed that.

There's a beta at http://www.csse.monash.edu.au/~damian//CPAN/Attribute-Handlers.tar.gz. Perhaps you and/or Marcel would like to see if it behaves more intuitively for you.


In reply to Re: Re (tilly) 1: autotie in Attribute Handlers by TheDamian
in thread autotie in Attribute Handlers by davorg

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.