It's a little hard to know where to start since you've touched on a lot of different topics in your, um, question. I think you owe it to yourself to do some reading on the topic then return with more specific questions if need be. I suggest
CGI Programming with Perl as well as
Writing Apache Modules with Perl and C. Both treat the subject of storing data used in web applications on disk and in memory. If you're serrious about building database applications, I suggest you also check out
Programming the Perl DBI which will show you how to use a
real database in your application.
-sam