note
ariels
<blockquote><i>...why can't <code>@foo</code> be treated as an implicit list for DWIM purposes?</i></blockquote>
Because you <em>asked</em> Perl to treat it specially!
<p>
Think of it like this: when you say <code>sub foo($)</code>, you're telling Perl to convert to a scalar the first arg of <code>foo</code>. When you say ``<code>foo(@foo)</code>'', <em>you</em> know that <code>@foo</code> has only one element (and therefore can assume you know what you mean), but perl doesn't. All perl looks at is the syntax of your code: an array is being used in a scalar context. So it gets converted to a scalar. Your "rule" for converting only works for 1-element <em>lists</em>; Perl's rule for converting an <em>array</em> to a scalar works for any size array.
<p>
It looks like another behaviour of Perl's conversion semantics that manages to confuse people.
173979
173979