for (@chain) { $chars .= $_->[$i]; }
Perhaps instead:
$chars = join "", map $_->[$i], @chain;
Try it both ways