In compiled languages, variables have no name. The name you see in the code is a unique identifier associated with some numerical offset. In the type identifier message_2 '2' serves only to make it a unique identifier. Anyone can say that you can make three variables: message_125 , message_216 and message_343 . While you can tell what you should invest in them, they work as well as message_1 ...
The "name" of a variable is just so that you save them directly while writing code.
Dynamic languages add features without clearing the character table (s). But a character table is simply an association of a name with a value. Since Perl offers you lists and hashes so cheaply, there is no need to use the software-logistic variable tracking method to provide flexible access at runtime.
Most likely, if you see lists of items @message1 , @message2 , ... - where the elements differ only in their reference order, these names are also good: $message[1] , $message[2] , ....
In addition, since character tables are usually mapped from name to offset (either on the stack or on the heap), this is really not much more than the pair of keys and values that you find in the hash. Thus, hashes work just as well as finding clearer names.
$h{messages} = []; $h{replies} = [];
I mean, indeed, if you wanted to, you could store everything you put in the lexical variable in a single hash for the region if you hadn't missed the entry: $h{variable_name} for everything. But you would not get the benefits of implicit visibility control in Perl and in different languages, programmers prefer implicit scope control.
Perl allows for symbolic manipulation, but over the years, dynamic languages have found mixed blessings. But in Perl, you have “perspectives” to give them a name. Since you can determine which code in a compiled language is more likely to be better than a dynamic language, it was determined that more errors use the “compiled perspective” for more things: the way you can see with bias and compiled search behavior provided to you in the Perl core, there is no reason to interfere with the symbol table if you do not need it.
Creating an array dynamically is as simple as: [] . Assigning this place in memory when we do not know how much we want to keep is as simple as:
push @message, [];
And creating a list of lists right away is simple:
@message = map { [] } 1..$num_lists;
for a specific value in $num_lists .