I not sure if you want a code to learning how to program a server on Perl or to use on a real production environment. Anyway, I recommend you to use
Net::Server or
POE. They will help you for both, learner and real program.
More information about POE "A Beginner's Introduction to POE".
Solli Moreira Honorio
Sao Paulo - Brazil