Journal Entry

Wednesday, September 6, 2017

Bits of writing geekery...

I was rooting around old drafts of The Unraveling today (which is still making the rounds; I am sprucing it up a bit further because reasons), and happened upon a lovely bit of cat-vacuuming: a Perl script to pull out, and highlight, every instance of a time-word in the text. I guess I was realizing that the various references to mealtimes and mornings and afternoons didn't add up, and wondering over how many actual days the principal action of the novel took place. And once you have a hundred-thousand-word blob of text, it's harder than you might think to answer such continuity questions for yourself. This probably took twenty minutes to write and, I vaguely recall, actually proved pretty useful. Here it is in all its hairy, undocumented, unrefactored glory, radiating shameless geekitude.


my @words = ("kitchen", "dining", "breakfast", "lunch", "dinner", "supper", "morning", "afternoon", "evening");

system ("echo > word.usages");

foreach my $w (@words) {
    my $cmd = "grep -ni '$w' >> word.usages";
    print "about to do: $cmd \n";
    print "processed $w\n";

open (IN, '< word.usages') or die 'could not open word.usages';
open OUT, '> word.usages.out';

while () {
	#todo do this with uppercasing, etc
    print OUT;
    print ">";
close IN;
close OUT;

system "sort -n word.usages.out | uniq >"
Posted by benrosen at September 6, 2017 12:51 AM | Up to blog
Post a comment

Please choose one:

Thank you. Remember personal info?