Help for this page

Select Code to Download


  1. or download this
    use List::Util 'sum';   # might be overkill
    
    ...
    # Arguably, this is less readable than your code
    printf("user: %d%%, nice: %d%%, total: %d%%, idle: %d%%\n",
       map { ($after[$_] - $before[$_]) * $scale } 0 .. 3);
    
  2. or download this
    my %hash;
    @hash{qw/ user nice total idle /} = cpu_stat();
    print "nice: $hash{nice}\n";