in reply to Populating Arrays of Arrays
First off, it is very good that you started with use strict! It'll definitely help you straighten these things out sooner than later.
In answer to your question
Why does a scalar defreference of an array force declarations to be made on the scalar and the array with the scalar name?Yes if you dereference an array and want to keep track of that reference, it'll have to be assigned into a scalar. However that scalar name doesn't have to correspond to the array name in any way.
Perhaps a written description of what you're trying to accomplish would help us figure out how to extrapolate what you have into what you want.
I can give you some ideas that may help... In my experience
Generally when I see looping structures like:
for (0...$#aoa)or
our $length=scalar @$val; for (0...$length-1)
that it may be possible to loop over an array (ie for my $item (@aoa) rather than the indicies of that array.
my @aoa = ('header',['html','head','body',], 'font',['font','face','size','color'], 'content',['h1','p','code'])
But this makes me think that you really wanted a Hash of Arrays (HoA) rather than an Array of Arrays (AoA). Which would be:
my %hoa = ('header',['html','head','body',], 'font',['font','face','size','color'], 'content',['h1','p','code'])
There are other things...but that's all I've got time for for now...
|
|---|