From owner-freebsd-questions@FreeBSD.ORG Wed Mar 26 14:47:37 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6D33A37B404 for ; Wed, 26 Mar 2003 14:47:37 -0800 (PST) Received: from caduceus.jf.intel.com (fmr06.intel.com [134.134.136.7]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9630E43F75 for ; Wed, 26 Mar 2003 14:47:36 -0800 (PST) (envelope-from steve@ichips.intel.com) Received: from talaria.jf.intel.com (talaria.jf.intel.com [10.7.209.7]) 20:43:23 dmccart Exp $) with ESMTP id h2QMhAi12990; Wed, 26 Mar 2003 22:43:10 GMT Received: from ichips-ra.pdx.intel.com (ichips-ra-hme1.intel.com [10.7.4.35]) 19:44:39 dmccart Exp $) with ESMTP id h2QMMl026477; Wed, 26 Mar 2003 22:22:47 GMT Received: from plxs0062.pdx.intel.com (plxs0062.pdx.intel.com [10.7.1.76]) h2QMlXJX028444; Wed, 26 Mar 2003 14:47:33 -0800 (PST) Received: from ichips.intel.com (localhost.pdx.intel.com [127.0.0.1]) id h2QMlX1c024334; Wed, 26 Mar 2003 14:47:33 -0800 Message-Id: <200303262247.h2QMlX1c024334@plxs0062.pdx.intel.com> X-Mailer: exmh version 2.2 06/23/2000 with nmh-0.27 To: Dan Nelson In-Reply-To: Message from Dan Nelson <20030326222940.GB38860@dan.emsphone.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 26 Mar 2003 14:47:33 -0800 From: Steve Willoughby X-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,IN_REP_TO,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) cc: freebsd-questions@freebsd.org Subject: Re: perl help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Mar 2003 22:47:38 -0000 > In the last episode (Mar 27), Giorgos Keramidas said: > > On 2003-03-26 14:18, Kenzo wrote: > > You don't need Perl for that. Here's a small trick: > > grep 'this' file | wc -l > > grep 'that' file | wc -l > Even better: > grep -c 'this' file > grep -c 'that' file Unfortunately, that's not what he was asking for, which is to look for the pattern "big " where all the possible s are unknown and report on all the s that were found. So something like: while (<>) { while (/big\s+(\w+)/g) { $count{$1}++; } } foreach $word (sort(keys(%count))) { print "$word: $count{$word}\n"; } ought to do the trick. Play with $/, etc if you want to allow big and to be across a newline from each other. -- Steve Willoughby | "The purpose of IT is to seamlessly and trans- Intel DPG Eng. Computing | parently provide the other nine-tenths of the Application Development | iceburg for people who need to work with chunks | of floating ice." --Strata R. Chalup