Path: utzoo!attcan!uunet!lll-winken!sun-barr!rutgers!mcnc!uvaarpa!mmdf From: worley@compass.com (Dale Worley) Newsgroups: comp.lang.perl Subject: Counting characters with unix utilities Message-ID: <1990Sep26.125033.19669@uvaarpa.Virginia.EDU> Date: 26 Sep 90 12:50:33 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: worley@compass.com Organization: The Internet Lines: 22 From: merlyn@iwarp.intel.com (Randal Schwartz) | perl -ne '$c += tr/A/A/; print $c if eof;' file | | Doesn't this fail if the file is empty? Ooops. I'll be out painting fence-posts for a while, sorry. :-) It seems like it would be useful to be able to prescribe prolog and epilog code for -n (and -p) loops. AWK does this with BEGIN and END. Then it would be simple: perl -ne '$c += tr/A/A/' -xxx 'print $c' file Dale Worley Compass, Inc. worley@compass.com -- Give yourself over to absolute pleasure Swim the warm waters of sins of the flesh Erotic madness beyond any measure And sensual daydreams to treasure... forever. -- Rocky Horror Picture Show