Re: Counting the same word

2002-09-17 Thread Mat Harris
i think this will work, but don't complain if it doesn't 'cos im tired. ok? #!/usr/bin/perl $count = 0; while (FILE) { if (m/california/) { $count++; } } print california: $count\n; On Tue, Sep 17, 2002 at 08:42:57 -0700,

RE: Counting the same word

2002-09-17 Thread Nikola Janceski
nope that only counts the word once per line.. if the word was in the line twice it would only count it once. -Original Message- From: Mat Harris [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 12:06 PM To: ANIDIL RAJENDRAN Cc: [EMAIL PROTECTED] Subject: Re: Counting

Re: Counting the same word

2002-09-17 Thread Mat Harris
the word once per line.. if the word was in the line twice it would only count it once. -Original Message- From: Mat Harris [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 12:06 PM To: ANIDIL RAJENDRAN Cc: [EMAIL PROTECTED] Subject: Re: Counting the same word i

RE: Counting the same word

2002-09-17 Thread Nikola Janceski
Are you only looking for 'california' (case-sensitive?) ? if so: open (FILE,C:\\proj\\order\.txt) or die cannot open file: $!; %seen = (); while (FILE) { $count += s/california//g; ## substitute returns number of subs (m// doesn't) } print california: $count\n; -Original

Re: Counting the same word

2002-09-17 Thread Tanton Gibbs
It depends on what you mean by word I would assume you could do something like %seen = (); while( FILE ) { $seen{lc $_}++ for( split /\s+/ ); } - Original Message - From: ANIDIL RAJENDRAN [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 17, 2002 11:42 AM Subject: