Hi all,

please have a look at the following code sample:

#!/usr/bin/perl use strict; use warnings; use 5.010; sub get_a_list { return qw(first mid last); } sub get_an_array { my @a = qw(first mid last); return @a; } my $a = get_a_list(); say "\$a: $a"; my $b = get_an_array(); say "\$b: $b";

While the behaviour of case 'b' is clear to me, I can't find an explanation for case 'a'. Can someone give me that explanation or a pointer to documentation explaining it? Why do I get the last element of the list and not the first. And why do I get the element count in case 'b' but not in case 'a'?

Thank you in advance.

Best regards
McA


In reply to Need explanatiin for subtle difference by McA

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.