This page permanently redirects to gemini://d.moonfire.us/blog/2012/05/01/an-obsession-with-data-a-k-a-writers-write/.
=> Up a Level
use strict; use warnings;
my %months = (); my $total = 0;
open FIND, “find ‘$ARGV[0]’ -type f -name ‘*.txt’ |” or die "Cannot open find ($!)";
while () { chomp; my $file = $_;
# Make sure the file has a date field. my $sep = $/; $/ = undef; open FILE, "<$file"; $_ = ; close FILE; $/ = $sep; next unless ($_ =~ m@* Date: (d+)-(d+)-d+@); my $year = $1; my $month = $2; # Figure out how many words. my $word_output = `wc -w "$file"`; next unless $word_output =~ m@^s*(d+)s+@s; my $words = $1; # Print the file. print STDERR "Processing $file ($year-$month) [$words]n"; my $key = "$year-$month"; $months{$key} += $words; $total += $words;
}
close FIND;
foreach my $y (qw(2007 2008 2009 2010 2011)) { foreach my $m (qw(01 02 03 04 05 06 07 08 09 10 11 12)) { $months{"$y-$m"} += 0; } }
foreach my $mkey (sort(keys(%months))) { my $words = $months{$mkey};
print "$mkeyt$wordsn";
}
print “nTotalt$totaln”;
Categories:
=> Programming | Writing
Tags:
=> Perl
Below are various useful links within this site and to related sites (not all have been converted over to Gemini).
=> Now | Contact | Biography | Bibliography | Support
=> Fiction | Fedran | Coding | The Moonfires
=> Categories | Tags
=> Privacy | Colophon | License
=> Mailing List
=> https://d.moonfire.us/blog/2012/05/01/an-obsession-with-data-a-k-a-writers-write/ This content has been proxied by September (3851b).Proxy Information
text/gemini;lang=en-US