This is what I have:
package Time::SinceStart; use strict; use Time::HiRes qw(gettimeofday); require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(getTimeSinceStart); our @EXPORT_OK = qw(getTimeSinceStart); our $VERSION = 1.0; my @pagestarttime = (); sub BEGIN { @pagestarttime = gettimeofday; } sub getTimeSinceStart { my @pagestoptime = gettimeofday; my $seconds = (abs($pagestoptime[0]-$pagestarttime[0])); my $decimals = (abs($pagestoptime[1]-$pagestarttime[1])); return ($seconds, $decimals); } 1;
The problem is, I get:
null: Use of uninitialized value in subtraction (-) at /Library/Perl/T +ime/SinceStart.pm line 24. null: Use of uninitialized value in subtraction (-) at /Library/Perl/T +ime/SinceStart.pm line 25.
Lines 24 & 25 are the my $seconds & my $decimals lines.
Now, there probably is a module for this (though I could not find it), but regardless, I'd also like to know what I do wrong. I'm guessing it has to do with global variables (oh, and this is run under mod_perl).
In reply to Finding out how long a script has been running by carthag
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |