PERL: Stopwatch + record

Is it possible to make a perl or cgi script that does the following ?

1) have a stopwatch with a start / start / pause feature and record the time its paused on. but be able to record up to ten different times
2)print the recorded time to .txt file

I don't have any sample code for you this is what I am thinking:

Make the start/stop/pause buttons so they post back to the same cgi and pass the time. You can push each time into an array. You can then subtract array[0] from array[1] to get the first time, array[1] from array[2] to get the second time, etc until the stop button is pressed which you would use as the last time.