Leshrac has already constructed that library you mentioned... IIRC, he's passing out beta copies.
Personally, I would advise against storing data in the user profile - I'd store it in external files, pulled in as required. The data is stored in a key/value format and is split into a hash when read. A reference to the hash is added as the last element of the user profile array when read. Thus, $userprofile[-1]->{'fieldname'} would always be valid. You'd never have to worry about array positions or any other such crap.