http://www.perlmonks.org?node_id=685086


in reply to String to two dimensional array

sub string2matrix { my( $x, $y, $s ) = @_; die "Can't create $x x $y matrix from string length: ", length $s unless length( $s ) == $x * 2 * $y -1; return map{ map{ [ split ] } $_ } unpack "(A@{[ $x * 2 ]})*", $s; } my $s = '0 X X X X X X X X 1 X X X X X X X X 2 X X X X X X X X 3 X X X + X X X X X 4 X X X X X X X X 5 X X X X X X X X 6 X X X X X X X X 7';; my @a = string2matrix( 8, 8, $s );; pp \@a;; [ [0, "X", "X", "X", "X", "X", "X", "X"], ["X", 1, "X", "X", "X", "X", "X", "X"], ["X", "X", 2, "X", "X", "X", "X", "X"], ["X", "X", "X", 3, "X", "X", "X", "X"], ["X", "X", "X", "X", 4, "X", "X", "X"], ["X", "X", "X", "X", "X", 5, "X", "X"], ["X", "X", "X", "X", "X", "X", 6, "X"], ["X", "X", "X", "X", "X", "X", "X", 7], ]

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.