[EMAIL PROTECTED] wrote:
>
I used the script Rob posted a few days with the list::util option and
it works. Thanks Rob!
However we also use systems we earlier versions of perl it seems. When
using the same script I find that it moans about Arrays being present
rather than an operator within the util.pm script.
Do we use the util.pm for sum only? If so can you change your script
slighty to work in the same way without using util or provide a way of
getting around the issue of being on an older version of perl?
(Please bottom-post your responses to this list so that extended threads
remain comprehensible. Thank you.)
This is the same program as I posted before but with the subroutine
sum() written explicitly instead of relying on List::Util.
HTH,
Rob
use strict;
use warnings;
my $file = shift @ARGV || 'cpuuse.out';
open my $fh, '<', $file or die $!;
my @cpu;
while (<$fh>) {
my @data = split;
push @cpu, $data[4];
}
print sum(@cpu) / @cpu;
sub sum {
my $sum;
$sum += $_ foreach @_;
return $sum;
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/