http://www.perlmonks.org?node_id=253718


in reply to peek - output a one-line preview of stdin

Let's add the ability to preserve the last line with --keep
my $wide = 79; my $keep=0; my %options = ( 'wide|width=i' => \$wide, 'keep' => \$keep ); GetOptions(%options) or die;
and
while (<>) { chomp; tr{\n\t}{\r }; $_ = substr($_ . $pad, 0, $wide); print "$_\r"; } if(!$keep) {print "$pad\r";} else {print "\n";} exit(0);