home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / perl / scripts-convex / chop < prev    next >
Encoding:
Text File  |  1991-07-22  |  321 b   |  19 lines

  1. #!/usr/bin/perl
  2.  
  3. $TIOCGWINSZ = 0x40087468;  # should be require sys/ioctl.pl
  4.  
  5. if (ioctl(STDERR, $TIOCGWINSZ, $winsize)) {
  6.     $cols = (unpack('S4', $winsize))[1];
  7. } else {
  8.     $cols = 80;
  9. }
  10.  
  11. $ARGV[0] =~ /^-(\d+)$/ && (shift, $cols = $1);
  12. $cols--;
  13.  
  14. while (<>) {
  15.     chop;
  16.     $_ = substr($_,0,$cols) . "\n";
  17.     print;
  18.