Re: Calculating Average from a file

2007-12-16 Thread Rob Dixon
[EMAIL PROTECTED] wrote: I've had to change the code as due to the earlier version of perl I am running the open line would not work. I found a workaround on the internet use strict; use warnings; my $file = shift @ARGV || 'cpuuse.out'; my %fh = (); if (-f $file and ! $fh{$file} ) {

Re: Calculating Average from a file

2007-12-14 Thread John W . Krahn
On Friday 14 December 2007 03:22, [EMAIL PROTECTED] wrote: > > All, Hello, > I've had to change the code as due to the earlier version of perl I > am running the open line would not work. > > I found a workaround on the internet > > use strict; > use warnings; > > > > my $file = shift @ARGV || '

Re: Calculating Average from a file

2007-12-14 Thread jase . critchley
All, I've had to change the code as due to the earlier version of perl I am running the open line would not work. I found a workaround on the internet use strict; use warnings; my $file = shift @ARGV || 'cpuuse.out'; my %fh = (); if (-f $file and ! $fh{$file} ) { open($fh{$file}, "<$fi

Re: Calculating Average from a file

2007-12-14 Thread Jase Critchley
I'm having to use an old version of perl on some systems and it doesnt like the format of the open my $file = shift @ARGV || 'cpuuse.out'; open my $fh, '<', $file or die $!; Is there another way of opening the file in the same way but different code? Thanks, Jase The sum function is j

Re: Calculating Average from a file

2007-12-14 Thread Chas. Owens
On Dec 14, 2007 6:02 AM, Jase Critchley <[EMAIL PROTECTED]> wrote: > I'm having to use an old version of perl on some systems and it doesnt like > the format of the open > > my $file = shift @ARGV || 'cpuuse.out'; > > open my $fh, '<', $file or die $!; > > Is there another way of opening the file i

RE: Calculating Average from a file

2007-12-13 Thread Jase Critchley
= $_ for @cpu; print $sum / @cpu; ?? Thanks, Jase. -Original Message- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: 12 December 2007 12:33 To: Jase Critchley Cc: beginners@perl.org Subject: Re: Calculating Average from a file On Dec 12, 2007 5:42 AM, <[EMAIL PROTECTED]>

Re: Calculating Average from a file

2007-12-12 Thread Rob Dixon
[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

Re: Calculating Average from a file

2007-12-12 Thread Chas. Owens
On Dec 12, 2007 5:42 AM, <[EMAIL PROTECTED]> wrote: > All, > > Thanks for your assistance in helping me with my issues. > > The script posted by Rob on the 7th works fantastic. > > However I've discovered that we have a lot of systems out there > running a previous version of perl, so much so that

Re: Calculating Average from a file

2007-12-12 Thread jase . critchley
All, Thanks for your assistance in helping me with my issues. The script posted by Rob on the 7th works fantastic. However I've discovered that we have a lot of systems out there running a previous version of perl, so much so that I am getting errors within the util.pm. "Array found where opera

Re: Calculating Average from a file

2007-12-12 Thread jase . critchley
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 th

Re: Calculating Average from a file

2007-12-08 Thread Dr.Ruud
John W . Krahn schreef: > Rodrick Brown: >> John W. Krahn: >>> perl -ane'$total+=$F[4]}{printf"Avg: %.2f\n",$total/$.' >>> /tmp/filename >> >> Hi John please explain how exactly $F[4] works? how is it set? Use -MO=Deparse to show you what Perl code your command line expression was compiled to.

Re: Calculating Average from a file

2007-12-07 Thread John W . Krahn
[ PLEASE! Do not top-post. ] [ Please remove any text not required for context. ] On Friday 07 December 2007 12:41, [EMAIL PROTECTED] wrote: > > On Fri, 7 Dec 2007, John W.Krahn wrote: > > > > On Friday 07 December 2007 04:36, [EMAIL PROTECTED] > > wrote: > >> > >> I am not very good at perl

Re: Calculating Average from a file

2007-12-07 Thread John W . Krahn
On Friday 07 December 2007 04:36, [EMAIL PROTECTED] wrote: > Hi, Hello, > I am not very good at perl however our systems use it and I am trying > to write a few scripts to help our staff. > > I am trying to calculate the average CPU utilisation from a log file > which is automatically generated.

Re: Calculating Average from a file

2007-12-07 Thread John W . Krahn
On Friday 07 December 2007 07:13, Rodrick Brown wrote: > > On Dec 7, 2007 9:45 AM, John W. Krahn <[EMAIL PROTECTED]> wrote: > > > > On Friday 07 December 2007 06:36, Rodrick Brown wrote: > > > > > > perl -nle '$total+= (split/\s+/,$_)[4]; END { printf "Avg: > > > %.2f\n", $total/$. } ' /tmp/filenam

Re: Calculating Average from a file

2007-12-07 Thread John W . Krahn
On Friday 07 December 2007 06:36, Rodrick Brown wrote: > > perl -nle '$total+= (split/\s+/,$_)[4]; END { printf "Avg: %.2f\n", > $total/$. } ' /tmp/filename perl -ane'$total+=$F[4]}{printf"Avg: %.2f\n",$total/$.' /tmp/filename John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [

Re: Calculating Average from a file

2007-12-07 Thread Rodrick Brown
perl -nle '$total+= (split/\s+/,$_)[4]; END { printf "Avg: %.2f\n", $total/$. } ' /tmp/filename On Dec 7, 2007 7:36 AM, <[EMAIL PROTECTED]> wrote: > Hi, > > I am not very good at perl however our systems use it and I am trying > to write a few scripts to help our staff. > > I am trying to calcula

Re: Calculating Average from a file

2007-12-07 Thread Rob Dixon
[EMAIL PROTECTED] wrote: I am not very good at perl however our systems use it and I am trying to write a few scripts to help our staff. I am trying to calculate the average CPU utilisation from a log file which is automatically generated. The columns are space seperated rather than comma. I

Calculating Average from a file

2007-12-07 Thread jase . critchley
Hi, I am not very good at perl however our systems use it and I am trying to write a few scripts to help our staff. I am trying to calculate the average CPU utilisation from a log file which is automatically generated. The columns are space seperated rather than comma. I found some code in this