Hello,

The correct Perl code to this problem
is this:

#!/usr/bin/perl -w
my $line = 0;
@ARGV = ("/Users/michel/Desktop/and.txt");
#write here the path to your file
$count = 0;
$word = 0;
#we initialize first the $count and $word scalars.
while (<>) {
               foreach $word (m/\band\b/ig) {
#\b here means here word boundaries
#if you don't know what it is see
#grep reference inside your BBEdit application.
#I have done here a case insensitive search
#if you want a case sensitive search remove the
#"i".
                   ++$count;
               }
           }
print "The number of occurencies of the word and is: ", $count,"\n";
#==========END============
Best Regards,
--
Michael Havlicek
On Mar 19, 2007, at 2:28 PM, Elie Boulos wrote:

I need to find the number of instances of an arbitrary string
in a single text file, is this possible through AppleScript?
Search matches doesn't have such a number.

For example, I need to find out the count of the word 'and' in
a text containing "He bought a hammer and a nail and a tape and
a screw driver" (that's 3 and's)

Possible?


-- ----------------------------------------------------------------------- -
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml>
List archives: <http://www.listsearch.com/bbeditscripting.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>



--
------------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml>
List archives: <http://www.listsearch.com/bbeditscripting.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to