use ProcessTable;
$p = new Proc::ProcessTable( 'cache_ttys' => 1 ); $ref = $p->table;
cache_ttys -- causes the constructor to look for and use a file that caches a mapping of tty names to device numbers, and to create the file if it doesn't exist (this file is /tmp/TTYDEVS by default). This feature requires the Storable module.
$process->uid
The priority and pgrp methods also allow values to be set, since these are supported directly by internal perl functions.
# A cheap and sleazy version of ps use Proc::ProcessTable;
$FORMAT = "%-6s %-10s %-8s %-24s %s\n";
$t = new Proc::ProcessTable;
printf($FORMAT, "PID", "TTY", "STAT", "START", "COMMAND");
foreach $p ( @{$t->table} ){
printf($FORMAT,
$p->pid,
$p->ttydev,
$p->state,
scalar(localtime($p->start)),
$p->cmndline);
}
perl(1).