http://www.perlmonks.org?node_id=790129

The symbol = is compiled into one of two assignment operators:

The following are considered to be aggregates:

There are two differences between the operators.

Context of Operands

The two operators differ in the context in which their operands are evaluated.

Value(s) Returned

The two operators differ in what they return.

ReturnsContext in which Assignment Operator is Evaluated
scalarlist
Operatorscalar assignmentThe LHS as an lvalueThe LHS as an lvalue
list assignmentThe number of scalars returned by the RHSThe scalars returned by the LHS as lvalues

Note that the right-hand side is used for the list assignment in scalar context.

Examples

ExamplesContext in which Assignment Operator is Evaluated
scalarlist
Operatorscalar assignment
# @array evaluated in scalar context. my $count = @array;
# The s/// operates on $copy. (my $copy = $str) =~ s/\\/\\\\/g;
# Prints $x. print($x = $y);
list assignment
# @array evaluated in list context. my @copy = @array;
# @array evaluated in list context. my ($first) = @array;
# Only dies if f() returns an empty list. # This does not die if f() returns a # false scalar like zero or undef. my ($x) = f() or die;
my $count = () = f();
# Prints @x. print(@x = @y);

Related topics:

Update: Added examples.
Update: Incorporated JavaFan's additions.
Update: Removed list slices and mentioned state.
Update: One of the examples in the scalar context column did not depend on context. It has been moved to its own column. Also, added short explanations of examples.
Update: Reworded to not say there are only two assignment operators, because += and such are also assignment operators.
Update: Reworded to include new fangled []->@* to the list of aggregates.