Given the experimental nature of :lvalue trumpeted in the Lvalue subroutines section of perlsub, I would be very reluctant to use it with a complex subroutine. If the Perl compiler can't even figure out the simple example code above, what hope for the vipers' nest of conditionals that is the _Var() workhorse?
Point taken -- but to it's credit, _Var was around for a few years BEFORE I added lvalue... i.e. I'd use it:
...(skipping prologue) my $p=main->SUPER::new({scalar=>1, arr=>[1,2,3,4], hsh=>{one=>1, two=>2, three=>3}}); #w/o lvalue: $p->scalar($p->scalar+1); $p->arr(1,22); $p->arr(3,$p->arr(3)+$p->arr(1)); $p->hsh("two",22); $p->hsh("total", $p->hsh("one")+$p->hsh("two")); P "arr=%s", [$p->arr]; P "hsh=%s", $p->hsh; Vs. w/lvalue: $p=$p->SUPER::new({arr=>[1,2,3,4], hsh=>{one=>1, two=>2, three=>3}}); ++$p->value; #or ($p->value++;) $p->arr(1) = 22; $p->arr(3) += $p->arr(1); $p->hsh("two") = 22; $p->hsh("total") = $p->hsh("one")+$p->hsh("two"); P "arr=%s", [$p->arr]; P "hsh=%s", $p->hsh; #both give same results: arr=[1, 22, 3, 26] hsh={one=>1, three=>3, total=>23, two=>22} arr=[1, 22, 3, 26] hsh={one=>1, three=>3, total=>23, two=>22}
For data that doesn't need runtime checking -- just dynamic allocation in a structure, the lvalue'd versions work great and are considerably less visual 'mess' to use, BUT, as you mention, experimental means semi-worthless for production code. As it is, I tend toward using the non-lvalue form in about 2/3rd of new *assignments*. But when you do a read-modify-write, the lvalue form is awfully tempting.

Gonna go poke at the return vals as suggested by Athanasius and see if that clears up the error...


In reply to Re^3: weird error message in middle-aged-perl(5.14) by perl-diddler
in thread weird error message in middle-aged-perl(5.14) by perl-diddler

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.