#!/usr/bin/perl # Sideways - a quick hack to rotate a text file through 90 degree ccw. # I use this for fixing the orientation from the banner program. # e.g. banner -w 50 Hello! | ./sideways.pl # Released under the X11 license use strict; my @txt; my $longest = 0; while(<>) { chomp; push(@txt, $_); if (length $_ > $longest) { $longest = length $_; } } for(my $i=$longest;$i>0;) { --$i; my $s = ""; foreach my $line (@txt) { # get the nth character from this line if ($i >= length $line) { $s .= " "; } else { $s .= substr($line, $i, 1); } } print "$s\n"; }