Training, Open Source computer languages

This is page ... -perl.html

Our email: • Phone: 01144 1225 708225

For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
how to read log and display in csv file using perl

Posted by jeetu (jeetu), 20 May 2008
Can any one help me writting a program to read log and display in csv file using perl.

Following is the Data of Log file.

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          4.61    0.00    0.31    0.34    0.00   94.75

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               4.26       100.09        77.30     336740     260084
dm-0             12.09        98.94        77.30     332898     260080
dm-1              0.03         0.27         0.00        896          0

top - 12:30:45 up 56 min,  1 user,  load average: 0.04, 0.01, 0.09
Tasks: 110 total,   1 running, 109 sleeping,   0 stopped,   0 zombie
Cpu(s):  4.6%us,  0.3%sy,  0.0%ni, 94.7%id,  0.3%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    775016k total,   422808k used,   352208k free,    26012k buffers
Swap:  1572856k total,        0k used,  1572856k free,   160152k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                        

Want to write the CSV with following values from the log file.

Device:Blk_read/s   Blk_wrtn/s  
time, load average,
Tasks: total, running, sleeping, stopped,  
Cpu(s):  us,  sy, id,  wa,  
Mem:  total, used,  free,
Swap:  total, used,  free,  cached

Posted by KevinAD (KevinAD), 20 May 2008
What have you tried so far? Do you know any perl?

Posted by KevinAD (KevinAD), 27 May 2008
Iguess the answer is nothing and no.

Posted by zamanfou (zamanfou), 28 May 2008
Very simple.
You can do it in many different ways..

1. dump the data into a variable.
   clear the data from useless info.
   go str8 to regexp stuff.

example: if ($data =~ /(Tasks:.*?sleeping)/) {
                   $tasks = $1
Well, if you dont know any perl, just forget it.
You better learn the basics.

Posted by jeetu (jeetu), 28 May 2008
well i was able to do it in PHP... it was quite easy....

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2023: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho