Yes, you're right. This is how I meant to define my array:
my @AoA = ( [ 1..12 ], [ 'A'..'L' ] );
Ok, what I need is for the AoA to be reformatted like this into another AoA.
1st 4 columns(1-4,A-D), "empty column", Next 4 columns(5-8,E-H) "empty row in AoA" Next 2 columns(9-10,I-J), "empty column", Last 2 columns(11-12,K-L)
Does this explain it?
I'm probably just slow, but not really no. Do you mean this?
my @super_array = ( [ [ 1..4 ], undef, [ 5..8 ] ], [ [ 'A'..'D' ], undef, [ 'E'..'H' ] ], undef, [ [ 9, 10 ], undef, [ 11, 12 ] ], [ [ 'I', 'J' ], undef, [ 'K', 'L' ] ] );
Just FYI, that's by far the scariest array I've ever tried to code up and I seriously doubt its usefulness.
Now, if you meant a boring two-dimensional table, that's MUCH easier and more sane.
my @array_2d = ( [ 1.. 4, undef, 5..8 ], [ 'A'..'D', undef, 'E'..'H' ], [ ], [ 9, 10, undef, 11, 12 ], [ 'I', 'J', undef, 'K', 'L' ] );
If it's neither of those, try me again. I'm dumb, but I won't give up. ;)
my @newAoA = (); for (my $startx = my $x = 4; $x <= 8; $x++) { for (my $starty = my $y = 7; $y <= 12; $y++) { $newAoA[$x - $startx][$y - $starty] = $AoA[$x][$y]; } }
Obviously this code doesn't work. It's a referencing issue. I would try to correct it, but I don't understand the goal. Can you try taking another stab at explaining how the array should look in the end?
BTW, this code is straight from Programming Perl 3rd ed. Chapter 9.
Way to hit a sore spot man! I just packed my copy of Programming Perl to move and I'm very emotional over it!!! :D
The code is okay. What was happening was that your @AoA was really just a long array of letters and numbers and didn't contain any internal references. Thus when the above code tried to dereference a 5 as an array, it would choke and die.
Hopefully something in my endless babble is helping you a little. I am trying! :) Are you just playing with some code, or do you have a goal I'm completely missing?
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]