Hello everyone,
I have a multidimensional array that I need to split into 4
multidimensional arrays. I've tried the examples from the Programming
Perl 3rd ed. Chapter 9 for splicing Arrays of Arrays and am not having
any luck.
Here's an example of how my data looks:
[1 2 3 4 5 6 7 8 9 10 11 12]
[A B C D E F G H I J K L]
Here's how I need it to look:
[1 2 3 4] [5 6 7 8]
[A B C D] [E F G H]
[9 10] [11 12]
[I J] [K L]
The code I used
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my @AoA = ();
push @AoA, qw[1 2 3 4 5 6 7 8 9 10 11 12];
push @AoA, qw[A B C D E F G H I J K L];
print Dumper([EMAIL PROTECTED]);
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];
}
}
print @newAoA;
The error I got is:
Can't use string ("5") as an ARRAY ref while "strict refs" in use at
./splice.pl line 16.
Any ideas?
Thanks in advance for any help!
--
Kevin Old <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]