use Tk; use Storable; # Say your config information is in notebook.db # and your config hash is %info. # At startup check if notebook.db exists and load it # into your config hash. If it dosn't exist then it means it's the # first run of the program and do something to make the notebook.db my %info; # global hash to hold your data if(-e 'notebook.db'){ %info = %{retrieve('notebook.db')}; # direct to hash }else{ make_notebook() } # now in your program, as you change things and want to # store them to the notebook.db, you need to save it. # Here is a list of Tk related statements that will automatically # save your notebook.db whenever you exit the program #setup auto save of storable db $mw->protocol('WM_DELETE_WINDOW' => sub { &save_it() }); $SIG{__DIE__} = sub { &save_it()}; $SIG{INT} = sub { &save_it()}; $mw->bind('', [sub{&save_it(); Tk::exit;}] ); # and the save_it sub sub save_it{ store(\%info,'notebook.db'); print "saved\n"; }