Help for this page
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);
my %hash; @hash{qw/ user nice total idle /} = cpu_stat(); print "nice: $hash{nice}\n";