McA has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Need explanation for subtle difference
by Athanasius (Archbishop) on May 26, 2015 at 10:07 UTC | |
by AnomalousMonk (Archbishop) on May 26, 2015 at 13:09 UTC | |
Re: Need explanatiin for subtle difference
by Anonymous Monk on May 26, 2015 at 09:55 UTC | |
by McA (Priest) on May 26, 2015 at 09:59 UTC | |
by Anonymous Monk on May 26, 2015 at 10:05 UTC | |
Re: Need explanatiin for subtle difference
by BillKSmith (Monsignor) on May 26, 2015 at 20:05 UTC |