On Tue, 9 Sep 2014 15:05:58 -0700
Jim Gibson <[email protected]> wrote:
> Some people make a distinction between 'list' and 'array'. A list is
> a sequence of scalar values indexed by an integer. An array is a
> variable whose value is a list (or something like that -- I don't
> really distinguish the two myself.)
A list can also be stored in a hash:
my %h = ( 'a', 1, 'b', 2, 'c', 3 );
Though, most times, people use the fat-comma notation:
my %h = ( a => 1, b => 2, c => 3 );
On Tue, 09 Sep 2014 18:35:50 -0400
Uri Guttman <[email protected]> wrote:
> to be a little more exact, lists live only in expressions and are on
> the stack. arrays can live between statements and are allocated from
> the heap.
That isn't much help since the Perl documentation does not mention the
calling stack or the heap (except `perldoc perlguts`, of course). And
Perl switches between lists and arrays very casually. For example, when
calling a sub you give it a list of arguments:
foo( 1, 2, 3 );
But Perl stores them in an array:
sub foo {
my ( $x, $y, $z ) = @_;
And the same thing happens with a return:
return ( $x, $y, $z );
my @a = foo();
--
Don't stop where the ink does.
Shawn
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/