I have a input file ,which has begin ... end patterns
some of the records are not delimitted end missing,

How do I separate records that dont have BEGIN and END ,
and  collect informtion of what ever date ,thats  in the record
two lines of data for each record,could be more lines

Write perl grammer tokenise the records ?


open(IN,"<iostat.txt");

while(<IN>){
if(/^BEGIN/ .. /^END/){
...
...collect the record
....
}
}


example INPUT,iostat output

===
BEGIN
Time: 04:43:29 PM
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1.59    0.04    5.13   10.49    0.00   82.75

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda              26.60       280.10       333.81   29294213   34911878
END
BEGIN
Time: 04:43:30 PM
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           9.00    0.00   88.00    3.00    0.00    0.00

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
BEGIN
Time: 04:43:31 PM
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           7.00    0.00   91.00    2.00    0.00    0.00

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda              91.00        56.00      1912.00         56       1912
END


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to