DB != cgi. I suggest the first place to look is in the Tutorials section here at Database Programming.
Using DBI in a light weight way is pretty easy and there are plenty of monks who can help with that. In like fashion, cgi is a very frequent topic of discussion here. However, it is probably much easier to approach the two areas one at a time. Combining them later on will be a snap, but learning two quite different and essentially unrelated things at the same time is likely to be a little fraught!
DWIM is Perl's answer to Gödel