Hi,
I have the following code that list down the starting
time of each process:
use Data::Dumper;
use Carp;
use Proc::ProcessTable;
use Time::Local::Extended qw(:ALL);
$FORMAT = "%-6s %-8s %-24s \n";
$t = new Proc::ProcessTable;
my $now = localtime;
print "NOW: $now\n";
printf( $FORMAT, "PID", "START", "TIME_DIFF" );
foreach $p ( @{ $t->table } ) {
my $start = $p->start;
#my $diff = $start - $now; #doesn't seem to work
my $diff = 1000; # this is just a dummy
printf( $FORMAT,
$p->pid, scalar( localtime( $p->start ) ), $diff
);
}
My problem is how can I find/print out the time difference (in seconds) for starting time and current time? Namely the time difference of:
my $now = localtime;
and
scalar( localtime( $p->start ) )