By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,372 Members | 1,950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,372 IT Pros & Developers. It's quick & easy.

Time Counter

P: 1
Can anyone tell the perl script that counts the time when we are online?
May 19 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 785
when he logs in, start counting the time with:
Expand|Select|Wrap|Line Numbers
  1. use Time::HiRes qw(gettimeofday tv_interval); #get better than 1 second resolution
  2. $startTime = [gettimeofday]; # starting time
when he logs out, requests a new webpage, or whatever event you want to measure, count the time with:
Expand|Select|Wrap|Line Numbers
  1. $currentTime = [gettimeofday]; # current time
  2. print tv_interval($startTime, $currentTime ); # print elapsed time.
May 19 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.