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: Counting the same word


Hi,
I want to count the number of times a particular  word occured in a file.
Though the  following script is working, is it possible to shorten it?

------

open (FILE,"C:\\proj\\order\.txt") or die "cannot open file: $!";
%seen = ();
while (<FILE>) {
 while ( /(\w['\w-]*)/g) {
  $seen{lc $1}++;
}
}
print "california: ". $seen{"california"}."\n";

------------



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to