in reply to Re: Array of arrays
in thread Array of arrays

Thank you both for the responses. I still get an error (following the advice in the first response). When I do, for instance:

print ("1st: $array1[0]"); print ("2nd: $array1[1]"); print ("3rd: $array1[2]"); print ("4th: $array1[3]"); print ("5th: $array1[4]"); print ("6th: $array1[5]"); print ("7th: $array1[6]"); print ("8th: $array1[7]"); print ("9th: $array1[8]"); print ("10th: $array1[9]"); print ("11th: $array1[10]"); print ("12th: $array1[11]");
I get the following error:
1st: ARRAY(0x7fd4bb012010) 2nd: ARRAY(0x7fd4bb02f768) 3rd: ARRAY(0x7fd4bb0120a0) 4th: ARRAY(0x7fd4bb012028) 5th: ARRAY(0x7fd4bb012070) 6th: ARRAY(0x7fd4bb02f648) 7th: ARRAY(0x7fd4bb045e80) 8th: ARRAY(0x7fd4bb0462e8) 9th: 10th: 11th: 12th : Use of uninitialized value $array1[8] in concatenation (.) or string Use of uninitialized value $array1[9] in concatenation (.) or string Use of uninitialized value $array1[10] in concatenation (.) or string Use of uninitialized value $array1[11] in concatenation (.) or string
The strange thing is I have 9 arrays (array1, array2, ..., array9) in my array of arrays. But even when I am only calling array1 (which should have ~200 indices), it seems to be considering each array in the array of arrays as simply an index in the first of its arrays??

Replies are listed 'Best First'.
Re^3: Array of arrays
by dbotham (Initiate) on Jul 19, 2013 at 05:25 UTC

    The 'ARRAY(0x7fd4bb012010)' lines are telling you that you are attempting to print a Reference to an array. So, to print the 1st array, do this:

    my @first_array = @{$array1[0]}; print @first_array;

    Or maybe better, to print all of the arrays:

    foreach my $array_ref (@array1) { print @{$array_ref}; }

    The remaining errors for 'Use of uninitialized value' are telling you that those parts of the parent array are not defined, and therefore cannot be printed (you would have to see the internal of perlfunc's print for the explanation behind the concatenation part...).

    David

Re^3: Array of arrays
by 2teez (Vicar) on Jul 19, 2013 at 03:43 UTC

    SuzuBell,
    If you are still having problems fixing your data structure to properly print your values out, use Data::Dumper module to see how your data structure is formed.
    Check what you are printing again and compare it with the previous solutions given.

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me
Re^3: Array of arrays
by Laurent_R (Canon) on Jul 19, 2013 at 18:00 UTC

    You have been given several suggestions of correction. We don't know what you have implemented and what not. Please show us the full code so that we know what you have now. Or show the output of a Data::Dumper dump command. Better yet, show us both.