$l=<>;$p=index($l," ")+1;@i=split//,$l;for$a(0..$p-1){print$i[$a+$_*$p]for(0..$p);print" "}
cat dog man yay
cdmy aoaa tgny
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!