my $data = "whatever"; my @pixels = [][]; for (my $i = 1; $i < $height; $i++) { (@pixels[$i][1 .. $width], $data) = split('', $data, $width); }