Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: Counting characters with unix utilities Message-ID: <1990Sep24.002258.1019@iwarp.intel.com> Date: 24 Sep 90 00:22:58 GMT References: <4002@umbc3.UMBC.EDU> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Followup-To: comp.unix.questions Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 26 In-Reply-To: emv@math.lsa.umich.edu (Edward Vielmetti) In article , emv@math (Edward Vielmetti) writes: | Going back to the tr man page this one seems to work too: | | cat file | tr -cd 'A' | wc -c | | I don't see an easy perl equivalent of the "tr -cd" idiom. You *will* in Perl 4.0 (coming real soon). Perl is being upgraded with a few new features so that it matches the new specification ("The Book"). The 'tr' operator gets a few new options, namely 'c', 'd', and 's', acting just like their tr(1) cousins. By the way, you don't need all those 'cat file' things. Just go: perl -ne '$c += tr/A/A/; print $c if eof;' file One process fits all. print "Just another Perl [book] hacker," -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/