J
Jim Gibson
Uri Guttman said:BC> } but the number of differences are more common:
BC> }
BC> } arrays lists
BC> } ------ -----
BC> You left out:
BC> evaluates to # of elements evaluates to last element
BC> in scalar context in scalar context
incorrect. there is no such thing as a list in scalar context. it is
just a series of comma ops in that situation, no list is ever created.
Here is something to ponder:
#!/usr/bin/perl
use strict;
use warnings;
sub returns_a_list
{
return ('a', 'b', 'c');
}
sub returns_an_array
{
my @r = ('d', 'e', 'f');
return @r;
}
my @a = returns_a_list();
print "a=@a\n";
my $x = returns_a_list();
print "x=$x\n";
my @b = returns_an_array();
print "b=@b\n";
my $y = returns_an_array();
print "y=$y\n";
__OUTPUT__
a=a b c
x=c
b=d e f
y=3
Note the difference between the values assigned to x and y!