#!/usr/bin/perl $TIOCGWINSZ = 0x40087468; # should be require sys/ioctl.pl if (ioctl(STDERR, $TIOCGWINSZ, $winsize)) { $cols = (unpack('S4', $winsize))[1]; } else { $cols = 80; } $ARGV[0] =~ /^-(\d+)$/ && (shift, $cols = $1); $cols--; while (<>) { chop; $_ = substr($_,0,$cols) . "\n"; print; }