DavidSzczesniak
12/7/2017 - 10:15 AM

Assigning arrays to scalars

# By default, only the length of the array will be assigned to the scalar; not the array's contents
# this is called a scalar assignment
@fred = (4, 5, 6); 
$a = @fred; # $a = 3, the current length of @fred

# However, if it's an array assignment like so:
($a) = @fred; # $a gets the first element of @fred
# the rest of the elements are discarded