in reply to String to two dimensional array
The basic idea is:my $text = "0 X X X ..."; my @items = split(' ', $text); my @array; while (@items) { push(@array, [ splice(@items, 0, 8) ]); } pp \@array; use Data::Dumper;
To make sure you have a full matrix, you can check the length of the last row with:
die "incomplete last row\n" unless (scalar(@{$array[-1]} == 8);
|
|---|