Turning LyX documents into Perl Scripts