in reply to perl error

The prefix character (also known as a sigil) for an element of an array (and hash) is often confusing for new-comers to Perl. It does not indicate the type of the variable name which follows it, but the type of the whole expression.
For example, take:
my @Matrix; $Matrix[$a] = 1;
Perl knows that 'Matrix' is an array because of the [ ] which follows the name (just as if it was a hash it would have { } following). The $ indicates the context of what is inside the [ ], in this case a scalar. Using @ would indicate that a list of indexes is inside the [ ], which is perfectly legal, and generally known as a slice.

The above only applies to Perl 5, Perl 6 is another country (but on the same continent).