Re: Count word's occurences
Re: Count word's occurences
- Subject: Re: Count word's occurences
- From: Guido Tangorra <email@hidden>
- Date: Tue, 09 Sep 2014 12:41:32 +0200
Thank you all for the advices!
My file is generated at runtime, so maybe the TextWrangler filter should be a good solution but I don't know how to use it in my script...
#!/usr/bin/perl -w
use strict;
my %occurrences = (); # set up empty hash
while (<STDIN>){ # read lines of file or present document
chomp; # remove linefeed and/or return
$occurrences{$_} ++; # fill hash with count of occurences
print "$_\t$occurrences{$_}\n";
}
How I can put this in my Counter handler to return the 'fruitQuantity'?
My script looks like this:
global myFruit, mySource
set theDocName to "My Fruit List"
set mySource to "htt
p
://..."
tell application "TextWrangler"
activate
set myDocument to make new text document with properties {name:theDocName}
end tell
on idle
tell application "JSON Helper" to set myFruit to fetch JSON from mySource
set fruitQuantity to my Counter(myFruit)
tell application "TextWrangler" to make new line at end of text of document theDocName with data (myFruit & return)
return 0.5
end idle
on Counter(theFruit)
...
end Counter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden