note
7stud
<code>$var1 = something1 ;</code>
<p>On the left of the assignment is a scalar variable. A scalar variable on the left of an assignment cries out, "Give me a scalar(single) value to store!" Similarly, an array variable on the left of an assignment:</p>
<code>@x = something;</code>
<p>...cries out, "Give me a list to store!"</p>
<p>Now look at this code:</p>
<code>
use strict;
use warnings;
use 5.012;
my @something = ('a', 'b', 'c');
my $x = @something;
my($y) = @something;
say $x;
say $y;
--output:--
3
a
</code>
<p>When $x cries out for a single value, the array provides its length. On the other hand, ($y) is a list, and it cries out for a list--so that list assignment can be performed:</p>
<code>
my @something = ('a', 'b', 'c');
my $d;
my $e;
my $f;
($d, $e, $f) = @something;
say $d;
say $e;
say $f;
--output:--
a
b
c
</code>
<code>
($d, $e) = @something;
say $d;
say $e;
--output:--
a
b
</code><code>
($d) = @something;
say $d;
--output:--
a
</code>
<code>
$d = @something;
say $d;
--output:--
3
</code>
<code>
my($s, $t, $u) = @something;
say $s;
say $t;
say $u;
--output:--
a
b
c</code>
1014216
1014216