8 my $too_long = shift @ARGV || 0.5; # s
11 open(my $lastcomm, '-|', 'lastcomm');
14 if ( m{^(\S+).+?(\S+)\s+(\S+)\s+(\d+\.\d+) secs} ) {
15 my ( $command, $user, $tty, $duration ) = ( $1, $2, $3, $4 );
16 $stats->{command}->{$command} += $duration;
17 $stats->{user}->{$user} += $duration;
18 $stats->{tty}->{$tty} += $duration;
19 print "$_\n" if $duration > $too_long;
25 foreach my $stat ( keys %$stats ) {
27 my $counter = $stats->{$stat};
28 foreach my $name ( sort { $counter->{$b} <=> $counter->{$a} } keys %$counter ) {
29 my $d = $counter->{$name};
30 printf "%8.2f %s\n", $d, $name if $d > $too_long;