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).
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|