Question: I sometimes see Perl code like this:

```
my ( $variable ) = blah....

```

What is the point of putting parentheses around a single variable? I thought parentheses were only used when declaring multiple variables, like:

```
my ( $var1, $var2, $var3 ) = blah...

```

Answer: 
There are several scenarios when there is a difference:

1. When **array** is on right side

```
my @array = ('a', 'b', 'c');
my  $variable  = @array;           #  3   size of @array
my ($variable) = @array;           # 'a'  $array[0]

```
2. When **list** is on right side

```
my  $variable  = qw/ a b c d /;    # 'd'  last  item of the list
my ($variable) = qw/ a b c d /;    # 'a'  first item of the list

```
3. Subroutine with variable (**array/scalar**) return value

```
sub myFunction {
  ...
  return (wantarray() ? @array : $scalar);
}
my  $variable  = myFunction(...);  # $scalar   from the subroutine
my ($variable) = myFunction(...);  # $array[0] from the subroutine

```
[*This answer is also found in table format [here](https://www.perlmonks.org/?node_id=790129).*]

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

* A *list assignment operator* (`aassign`) is used if the left-hand side (LHS) of a `=` is some kind of aggregate.
* A *scalar assignment operator* (`sassign`) is used otherwise.

The following are considered to be aggregates:

* Any expression in parentheses (e.g. `(...)`)
* An array (e.g. `@array`)
* An array slice (e.g. `@array[...]`)
* A hash (e.g. `%hash`)
* A hash slice (e.g. `@hash{...}`)
* Any of the above preceded by `my`, `our` or `local`

There are two differences between the operators.

Context of Operands
-------------------

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

* The scalar assignment evaluates both of its operands in scalar context.

```
  # @array evaluated in scalar context.
  my $count = @array;

```
* The list assignment evaluates both of its operands in list context.

```
  # @array evaluated in list context.
  my @copy = @array;

```

```
  # @array evaluated in list context.
  my ($first) = @array;

```

Value(s) Returned
-----------------

The two operators differ in what they return.

* The scalar assignment ...

	+ ... in scalar context evaluates to its LHS as an lvalue.

	```
	  # The s/// operates on $copy.
	  (my $copy = $str) =~ s/\\/\\\\/g;

	```
	+ ... in list context evaluates to its LHS as an lvalue.

	```
	  # Prints $x.
	  print($x = $y);

	```
* The list assignment ...

	+ ... in scalar context evaluates to the number of scalars returned by its RHS.

	```
	  # 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;

	```

	```
	  # $counts gets the number of scalars returns by f().
	  my $count = () = f();

	```
	+ ... in list context evaluates to the scalars returned by its LHS as lvalues.

	```
	  # Prints @x.
	  print(@x = @y);

	```