If I'm correct the main problem is sharing variables between
invocations of a script or cross-script. You could use Cache::Cache to store and fetch your variables. Specifically Cache::FileCache is very useful for this.
Comment on Re: Sharing Global variables between scripts