.
On 5/2/06, Charles K. Clarkson <[EMAIL PROTECTED]> wrote:
Anthony Ettinger wrote:
: #!/usr/bin/perl -w
:
: use vars qw($start_time $end_time);
: use strict;
:
: BEGIN {
: $start_time = time();
: }
:
: sub log_time {
: my $exit_code = shift;
: my $elapsed_time = $end_time - $start_time;
:
: print $elapsed_time, "\n";
: }
:
: END {
: $end_time = time();
: &log_time($?);
: }
:
: __END__
BEGIN {
my $start_time = time();
sub log_time {
# my $exit_code = shift;
print time() - $start_time, "\n";
}
}
END {
log_time($?);
}
Or, if this is not a persistant perl enviroment, like
modperl, just this.
END {
# $^T is the time at which the program began
# running, in seconds since the epoch.
print $^T - time(), "\n";
}
ok, I can ditch the BEGIN block altogether and use $^T - time(); in the END
block...
I would have to move the call to log_time(); to the END block, since it
doesn't make sense to do it at startup.