# [Perl 5], 163 bytes <!-- language-all: lang-perl --> $"=$,;@a=map[/./g],<>;while(@a){say' 'x$d."@{$a[$_]}"for 0..@a-2;$d+=@a;say$s.="@{pop@a}";@b=();for$i(0..$#a){$b[$_][$#a-$i]=$a[$i][$_]for 0..$#{$a[$i]}}say;@a=@b} [Try it online!][TIO-j6mjqmdq] [Perl 5]: https://www.perl.org/ [TIO-j6mjqmdq]: https://tio.run/##Lc7fCoIwFMfx@55C5gGVdFrg1Vqs/3XRE8iIiVYDy6FBhezVWxt1d/jx5cNRddfkxgCiEBMm6E2oIsXphcezOXleZVOHTERDL96BF7ygwogNIAo4cY3ObedlGDORTAlUY8oEsR30mNpItYoJjQgraRgRm4IMbQy@1aB0QGHvBCSnzpPcTX8R/OG3aW1B9xYrtTG77Wa0P6xHi@Xq06qHbO@9SY45zibZFw "Perl 5 – Try It Online"