in reply to averaging a group of lines with numeric value in a text file

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