use strict; use warnings; use Text::Autoformat; my $text = do { local $/; <>; }; my $formatted = autoformat $text, { left => 1, right => 38, justify => 'full', all => 1 }; my @lines = split /\n/, $formatted; if ( @lines > 50 ) { my $lines = int( ( @lines + 1 ) / 2 ); $formatted = ''; for ( 0 .. $lines - 1 ) { $formatted .= sprintf "%-38s %-38s\n", $lines[$_], ( $lines[ $_ + $lines ] ? $lines[ $_ + $lines ] : '' ); } } print $formatted;