G'day Anas,

Welcome to the Monastery.

It's difficult to discern what's descriptive text and what's data. Please always put your data within <code>...</code> tags; do the same for code and any output which appears to you in a fixed-width font (e.g. error messages). This allows us to see exactly what you see and to download a verbatim copy (e.g. for fixing, testing, etc.).

As already pointed out, if you don't show us what you tried, we can't really provide much in the way of improvements, fixes, and so on. Please post your code and explain what part of it you are having difficulties with. Here's a couple of hints, but it's purely guesswork on my part and may, in fact, be no help at all.

Your file looks like it contains CSV data with space separators. Text::CSV has been specifically written to handle this type of data: I recommend you use it. If you also have Text::CSV_XS installed, it will run faster.

You can probably use $., the input line number, in your averaging calculations.

Update: Some minor typos corrected. No substantive change to original information.

— Ken


In reply to Re: averaging a group of lines with numeric value in a text file by kcott
in thread averaging a group of lines with numeric value in a text file by Anas

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.