- or download this
use strict;
use warnings;
- or download this
while()
- or download this
while(1)
- or download this
{
my @loads;
my $i = my $cpuload = 0;
open(INFIL,"< /proc/stat") || die("Unable To Open /proc/stat\n");
- or download this
<INFIL> =~ /^cpu\s+(\d+)\s+(\d+)\s+(\d+).*/;
@loads = ($1, $2, $3);
- or download this
my @loads = (<$fh> =~ /\d+/g)[0,1,2];
- or download this
local $_=<$fh>;
(warn "something wrong!\n"), next
unless /^cpu\b/;
my @loads = (/\d+/g)[0..2];
- or download this
sleep 1;
seek INFIL, 0, 0;
<INFIL> =~ /^cpu\s+(\d+)\s+(\d+)\s+(\d+).*/;
foreach ($1, $2, $3) { $cpuload += $_ - $loads[$i++]; }
close(INFIL);