I have a script that checks how many lines are added per second, and the total number of lines. I want to be able to have the data of $line_count , be stored temporary every 10 changes or intervals, then have all the numbers averaged.. i myself have NO clue how to do this.. any math wiz's out there help me out.. the code is below.
#!/bin/perl use Term::ANSIColor; use Term::ANSIColor 2.00 qw(:pushpop); use File::Tail; my $file=File::Tail->new("output.txt"); my $last_time = time(); my $line_count = 0; while (defined($line=$file->read )){ if ( time() > $last_time ){ $last_time = time(); open(FILE, "output.txt"); @lines = <FILE>; close(FILE); $num = @lines; system 'clear'; print colored("Bots p/s: $line_count\n", "green"); print colored("Total Bots: $num\n", "green"); print " \n \n \n"; print color 'reset'; $line_count = 0; } $line_count++; }

In reply to Reading the average of a changing varible by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.