Here is how you do it:
use strict;
use warnings;
for( 1 .. 100 ) {
no strict 'refs';
@{'H' . $_} = ();
}
And here's "Why it's stupid to `use a variable name as a variable name'" (in other words, why you shouldn't), in three parts:
- Part I: Why it's stupid to `use a variable name as a variable name'
- part II: A More Direct Explanation of the Problem
- part III: What if I'm Really Careful?
And here's what you probably should be doing instead:
use strict;
use warnings;
my @H;
for( 1 .. 100 ) {
push @H, [];
}
The latter gives you an array, "@H" containing elements 0 through 99, each of which contains a reference to an array. In both cases, presumably you would actually have something to put into the arrays more meaningful than an empty list, so obviously these are just examples. Now it's time to read perllol.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.