A simple script to show a table of contents like view of a latex file. I could make a couple of assumptions about the input based on my setup. My first attempt which is probably somewhere on my blog looked like this:
Perl:
if($#ARGV > 0) { $in_file_name = shift; }
else { $in_file_name = "thesis.tex"; }
sub read_file
{
while(<IN>) {
if(/^\\chapter.?
{(.+?
)}/
) {print "——————–\n$1\n";
}
elsif(/^\\section.?
{(.+?
)}/
) {print " . . $1\n";
}
elsif(/^\\subsection.?
{(.+?
)}/
) {print " . . . . $1\n";
}
elsif(/^\\subsubsection.?
{(.+?
)}/
) {print " . . . . . . $1\n";
}
elsif(/^\\paragraph.?
{(.+?
)}/
) {print " . . . . . . . . $1\n";
}
elsif(/^\\input{(.+?)}/) {read_file($1);}
}
}
read_file($in_file_name);
A classic recursive solution using a function. I had a quick play today and produced this:
Perl:
#!perl -n
/^\\chapter.?
{(.+?
)}/
and print "-" x20 .
"\n$1\n" or
/^\\section.?
{(.+?
)}/
and print " ." x2 .
" $1\n" or
/^\\subsection.?
{(.+?
)}/
and print " ." x4 .
" $1\n" or
/^\\subsubsection.?
{(.+?
)}/
and print " ." x6 .
" $1\n" or
/^\\paragraph.?
{(.+?
)}/
and print " ." x8 .
" $1\n" or
/^\\input
{(.+?
)}/
and system "perl list_sections2.pl $1";
Which is a lot more compact. It’s almost inefficient, but this doesn’t really matter for this problem (or at least the input I have).
Which one feels more Perl-y?
Or should I just give up on Perl and go back to my Pythonic ways?
Seem to have to do these semi-regularly. At least you know when you need to update from the admin page. And so far the updates have been fairly seamless.
On another note, it’s progress report time. Started work on a new progress report this morning in the train. Looks decent already but needs a bit more work yet. Always interesting to look back and see what you’ve done over the past 6+ months.
I’ve regenerated a lot of results, learned a bit about statistical analysis of these results, made a host of new graphs and such. Simulations and other experiments are included here. I’ve finished off the writing of the first draft of my dissertation and Tony has read over the whole thing. I’ve incorporated a lot of his comments, but there are still more to go. I’ve presented one paper, had another accepted and submitted another (the latter two are mentioned in the previous post). I’ve completely failed to meet my earlier deadlines due to working too much.
Progress and progress and I am making some. Doing a report is always a bit annoying as its time spent not working on the PhD itself, but I should have this finished before too long; I don’t believe anybody will care if its not 100% polished.
Running emulation tests again back in NZ. They have been running for around 24 hours but look like they’ll need a further couple of days before they’ll show me the data I want. So far the results look good but the tests haven’t really got down to the bit I’m interested in yet (Linux 2.6 performance, only have OpenBSD results so far).
Simulation results look fine. Simulating the scenario was much quicker! (and didn’t require a network of 6 machines and so on…. Hooray for simulation. Well, if its correct. When the emulations finish I should be able to say whether it is).
Submitted a paper to a conference and got news of acceptance from a journal. Good times.