http://qs321.pair.com?node_id=759475

ELISHEVA has asked for the wisdom of the Perl Monks concerning the following question:

Recently I discovered that foo() evaluates in array context in "${\foo()}", e.g.
use strict; use warnings; sub foo { wantarray() ? 10 : 1; } print "${\foo()}\n"; #outputs 10

I would have expected that the $ sigil would have biased "${...}" towards a scalar context since the obvious value inside of {...} would naturally be a scalar reference. Thus the thing that "\" takes a reference from should be presumed to be a scalar. Apparently this is not so.

I'm wondering if any of the Perl language design/internals gurus here would care to enlighten me? Perl generally tries to "do what is expected" (by the programmer). What was the expected understanding that behind the current behavior?

Thanks in advance, beth