You might try investigating the perl module
AnyData. I've never used it, and in fact only just learned of it, but perhaps it will allow you to do this. Of course, you'll need to understand a little about
tieing.
If you do decide to play with this and get it working, it would be nice if you could post code so that others will have an example.