#!/usr/bin/perl -w # Rotate text input counterclockwise. # # 2018-01-15 use strict; my @lines = <>; my $height = 0; foreach (@lines) { s/\s*$//s; $height = length($_) if $height < length($_); } for(my $y = $height - 1; $y >= 0; $y--) { for(my $x = 0; $x <= $#lines; $x++) { print $y < length($lines[$x]) ? substr($lines[$x], $y, 1) : ' '; } print "\n"; }