From owner-freebsd-questions@FreeBSD.ORG Thu Mar 27 06:45:17 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 07B1737B401 for ; Thu, 27 Mar 2003 06:45:17 -0800 (PST) Received: from hotmail.com (dav22.sea1.hotmail.com [207.68.162.79]) by mx1.FreeBSD.org (Postfix) with ESMTP id 71D0443FA3 for ; Thu, 27 Mar 2003 06:45:16 -0800 (PST) (envelope-from kenzo_chin@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 27 Mar 2003 06:45:16 -0800 Received: from 209.187.233.156 by dav22.sea1.hotmail.com with DAV; Thu, 27 Mar 2003 14:45:15 +0000 X-Originating-IP: [209.187.233.156] X-Originating-Email: [kenzo_chin@hotmail.com] From: "Kenzo" To: Date: Thu, 27 Mar 2003 08:45:15 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: X-OriginalArrivalTime: 27 Mar 2003 14:45:16.0216 (UTC) FILETIME=[7B035B80:01C2F46F] X-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) Subject: Fw: 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: Thu, 27 Mar 2003 14:45:19 -0000 Bounced try again. ----- Original Message ----- From: "Kenzo" To: Sent: Thursday, March 27, 2003 8:28 AM Subject: Re: perl help > This works great. > now I just realized something else. > What if I wanted to show and count everything after a specific word. > > if I have a sentence like this. > I went to the store with joe/mike and paul > > I want to show how many times "joe/mike and paul" appears. > > The script below will only show joe if I input the word with. > so the desired output would be > joe/mike and paul 40 > > then if I have a similar sentence like > I went to the store with paul and mike > the output will would be > paul and mike 25 > > Thanks. > > ----- Original Message ----- > From: "Steve Willoughby" > To: "Dan Nelson" > Cc: > Sent: Wednesday, March 26, 2003 4:47 PM > Subject: Re: perl help > > > > > 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 > > > > > > _______________________________________________ > > freebsd-questions@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" > > >