On 2009-10-18 at 5:35 PM, [email protected] (Jonathan Lundell) wrote: >Bruce, how are you handling the % fortune separator?
Not sure what you are referring to. >On Oct 18, 5:22 pm, Bruce Van Allen <[email protected]> wrote: >> On 2009-10-18 at 4:52 PM, [email protected] (Bruce Van Allen) wrote: >> >> >On 2009-10-18 at 4:17 PM, [email protected] (Bruce Van Allen) wrote: >> >> >>Try this untested script (provide filenames and add your own >> >>list of skipped words below __END__): >> >> >OK, that was untested and I just tested it and there's a thinko. >> >Hang on a minute. >> >> Here we are: >> >> #!/usr/bin/perl -w >> >> my %sort_buckets; >> my %exclusions; >> >> # provide filenames: >> my $file_to_sort = '/path/to/file_to_sort'; >> my $sorted_file = '/path/to/sorted_file'; >> >> while (<DATA>) { >> chomp; >> $exclusions{$_}++; >> >> } >> >> open $in, "<", $file_to_sort >> or die "Can't open file: $!"; >> >> while (<$in>) { >> my $line = $_; >> my @words = split " " => $line; >> my $sort_key = ''; >> for (0..$#words) { >> if ($exclusions{lc($words[$_])}) { >> next; >> } else { >> $sort_key = join "" => map { lc($_) } @words[$_..$#words]; >> last; >> } >> } >> $sort_buckets{$sort_key} = $line; >> >> } >> >> close $in; >> >> open $out, ">", $sorted_file >> or die "Can't open file: $!"; >> >> foreach (sort keys %sort_buckets) { >> print $out $sort_buckets{$_}, "\n"; >> >> } >> >> close $out; >> >> __END__ >> a >> the >> this >> that >> you >> when >> is >> may >> be >> if >> i >> have >> >> - Bruce >> >> _bruce__van_allen__santa_cruz_ca_ >> - Bruce _bruce__van_allen__santa_cruz_ca_ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group. -~----------~----~----~----~------~----~------~--~---
