in reply to statefulness and Perl
I would store all my program's runtime variables in a hash, and write that hash to an sqlite database. When starting up, the program just reads the db and does what it needs to do.