Try to start at cpan, most of the work is already done for you.
In your case, look at Statistics::Lite
Next, try the tutorial-section
of this site to get you started in perl.
"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.