No, that much is clearly understood. What I mean is that with respect to function prototypes, passing an array to a scalar prototype would seem to be a type mismatch, although these are kind of relative in such a loosely typed language as Perl. You'd hope for a warning, perhaps. You've asked for a scalar, but you're getting a list.

What I was expecting was that the @foo array would be expanded into the brackets in the function call and passed through as a list, but Perl appears to be doing some truly clever things to try and handle the prototype, taking it to the ultimate extreme.

Update:
japhy and everyone else who has been kind enough to post remarks on this subject is 100% correct, of course. What led to this insight into prototypes was one part ass, one part you, one part me, and we all know what that adds up to.

The counter-intuitive component of this is that I'd expected an automatic array-to-list conversion to be peformed before said list is then passed to the prototype, but this is not the case. A list of an array is not the same as a list of the array elements.

In reply to Re^2: Function Prototype Context Conversion by tadman
in thread Function Prototype Context Conversion by tadman

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.