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, ANIDIL RAJENDRAN wrote: > 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"; > > ------------ -- Mat Harris OpenGPG Public Key ID: CC14DD34 [EMAIL PROTECTED] matthewh.genestate.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]