in reply to NTP and perl
NTP has exactly one function - to keep the time on a computer correct with reference to other computers. It is much more than a communications protocol. It use some quite elaborate modelling to keep the time on the client synched with (very) high precision to the time on the server.
You could, at least in principle, rewrite the NTP programs in Perl, but this seems a little pointless. Perl is not a good langauge for doing lots of iterative calulations.
Have a look at the tutorial at http://www.eecis.udel.edu/~ntp/. Personally I think fletch is on the right track, if you need what I think you need.