The way I see it, ${ EXPR1 } forces scalar context and then performs a scalar dereference on EXPR1.

The backslash \( EXPR2 ) forces list context on EXPR2 and returns a list of references.

By combining the two, you have \foo() returning a list of one reference to scalar 10. Then, ${ (\10) } returns the scalar dereferenced 10.

FYI, there's a catch to using the \( ) syntax for @arrays:
> perl -de '' DB<1> x @array = (1 .. 3) 0 1 1 2 2 3 DB<2> x \(@array, (@array)) 0 ARRAY(0x844cad8) 0 1 1 2 2 3 1 SCALAR(0x844e420) -> 1 2 SCALAR(0x844ca3c) -> 2 3 SCALAR(0x844cb80) -> 3 DB<3> x \(@array) 0 SCALAR(0x844e420) -> 1 1 SCALAR(0x844ca3c) -> 2 2 SCALAR(0x844cb80) -> 3 DB<4> x \(@array, ()) 0 ARRAY(0x844cad8) 0 1 1 2 2 3

Update: BTW, same catch applies to %hashes.

In reply to Re: Why does foo() evaluate in array context in "${\foo()}"? by repellent
in thread Why does foo() evaluate in array context in "${\foo()}"? by ELISHEVA

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.