array of arrays - context problem by Anonymous Monk
<SNIP>
my @masterarray = qw(@array1 @array2 @array3);
You do not have an "array of arrays" at all. C<qw//> is for defining list of "words", and it does not interpolate, as explained clearly in 'perldoc perlop'. Also, you do not have a "context problem" at all.
This will print out the name of each array, but how can I get it to print out the contents of each array? or the number of elements in each array instead?If you really want to print the contents of each array by its name, then you can use symrefs, but since you do not to do that (believe me!) I'm not even mentioning how to do it. Depending on what you really want to do you may want either
ormy @masterarray = (@array1, @array2, @array3);
The latter seems more probable from your description. Then to obtain the number of elements in each of them you can try e.g.:my @masterarray = (\@array1, \@array2, \@array3);
You can also use scalar(), but it takes a few more keystrokes...my @lengths = map 0+@$_, @masterarray; # (untested!)
In reply to Re: array of arrays - context problem
by blazar
in thread array of arrays - context problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |