<p>Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array <code>@myarray</code> and a hash <code>%myhash</code>, why do you need to do:</p>

<pre><code>$x = $myarray[1];
$y = $myhash{'foo'};
</code></pre>

<p>instead of just doing :</p>

<pre><code>$x = myarray[1];
$y = myhash{'foo'};
</code></pre>

<p>Why are the above ambiguous? </p>

<p>Wouldn't it be illegal Perl code if it was anything but a $ in that place? For example, aren't all of the following illegal in Perl?</p>

<pre><code>@var[0];
@var{'key'};
%var[0];
%var{'key'};
</code></pre>

I can think of one way that
```
```
$x = myarray[1];
```
```
is ambiguous - what if you wanted a array called m?
```
```
$x = m[1];
```
```
How can you tell that apart from a regex match?
In other words, the syntax is there to help the Perl interpreter, well, interpret!