carthag has asked for the wisdom of the Perl Monks concerning the following question:
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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding out how long a script has been running
by japhy (Canon) on Jun 21, 2002 at 16:10 UTC | |
by carthag (Scribe) on Jun 21, 2002 at 16:13 UTC | |
|
Re: Finding out how long a script has been running
by Abigail-II (Bishop) on Jun 21, 2002 at 16:31 UTC | |
by carthag (Scribe) on Jun 22, 2002 at 13:52 UTC | |
|
Re: Finding out how long a script has been running
by little (Curate) on Jun 21, 2002 at 16:55 UTC | |
|
Re: Finding out how long a script has been running
by lshatzer (Friar) on Jun 21, 2002 at 16:52 UTC | |
by shotgunefx (Parson) on Jun 21, 2002 at 18:37 UTC |