You'd probably be much better off using a hash here.
$hash{'abacus'} = ([1,2,3,4,5]);
$hash{'querty'} = ([6,7,8,9,10]);
So then $hash{'abacus'} and $hash{'qwerty'} are array references you can read like:
print $hash{'abacus'}[0]; # Prints "1"
print $hash{'qwerty'}[1]; # Prints "7"
Then you also have the advantage of easy access to all your
array "names" by using keys %hash
| [reply] [d/l] [select] |
Ok. It's worked.
But this is hash, no array :(
How me made this use array?
Thx, Chewby
| [reply] |
It's actually a hash of arrays. That is, it is like a standard hash, but instead of the values being scalars, they are array references:
my %data = (
'abacus' => [ 1, 2, 3, 4, 5],
'qwerty' => [ 5, 4, 3, 2, 1]);
This way, you can refer to the arrays by name without having to use symbolic references (you can store array names in variables, and use those variables as keys to the hash -- that will prevent some subtle errors).
See perlref and perldsc for more information. It's a very powerful technique. | [reply] [d/l] |
$a ='string1';
@$a[0] = 'string2';
print @string1;
What exactly is your problem?
Addition:oops -
Note however that this will not work if you have
use strict;
which is always a good idea.
I would examine why you want to write your code in this way as I am sure there is a 'better' way of doing it.
If you could show more of your code I/we could probably give you a better answer. | [reply] [d/l] [select] |