[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] change makedictionary script



Hi Fellow Perlers,

I have a script that Alan Fry (Yeah! Boom! Yahoo!) made me. The script
seperates words in a document and puts them in a list. I have written a
program in Java that will use this list of words,
http://www.sonic.net/~star/sierra.html but, alas, the words must be in
quotation marks seperated with a comma. For example:
"fooooo",
"whooo",
"etc......",

How would we be able to make the script  pick 5 letter words or longer only?
Heres the script........


#!perl

if (!open(IN, $ARGV[0])) { exit }
open (OUT, ">:newDict");
MacPerl::SetFileInfo("R*ch","TEXT", newDict);

@text = <IN>;

foreach $line (@text) {
    foreach (split(/ /, $line)) {
        if ( /[A-Z]/ ) { next }
        tr/A-Z/a-z/;
        s/[^a-z]//g;
        if (! /[a-z]+/) { next }
        if (length $_ > 10) { next }
        if (length $_ <= 1) { next }
        if (defined $dict{$_}) { next }
        else { $dict{$_} = $n; $n++ }
    }
}

@myDict = sort (keys %dict);
foreach (@myDict) { print OUT $_, "\n" }
print scalar @myDict

Thanks!
~arthur



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch