home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / perl / scripts-convex / clones / wc < prev    next >
Encoding:
Text File  |  1991-08-09  |  383 b   |  16 lines

  1. while (<>) {
  2.     $lines++;
  3.     $chars += length;
  4.     $words++ while /\b./g;
  5.     next unless eof;
  6.  
  7.     printf " %7d %7d %7d %s\n", $lines, $words, $chars, ($ARGV eq '-'?'':$ARGV);
  8.  
  9.     $tlines += $.; 
  10.     $twords += $words; 
  11.     $tchars += $chars; 
  12.     $chars = $words = $lines = 0;
  13.     $files++ if eof();
  14. }
  15. printf " %7d %7d %7d %s\n", $tlines, $twords, $tchars, "total" if $files++;
  16.