See the appendices in the thesis for the Perl code used in the thesis.