Hi -

Please help me with the following. I have to a parse a log file and here is the part of the log file which is occurs repetitively.

[Text1] [Text2] [Text3] [Text4] [Text5] [Text6] [Text7] [

===== PATTERN1 =======

Text8_line1: value1

Text8_line2: value2

Text8_line3: value3

Text8_line4: value4

.

.

.

Text8_linen: valuen

===== PATTERN1 =======

]

So basically I want to copy the text (i.e. Text1,Text2, ...... Text8) into different array or scalar variable for further processing. The brackets ([ and ]) for Text 8 are in different lines.

Please help me with this.

Thanks.

-Navsaug

Recommended Answers

All 3 Replies

I'm not sure if I understand exactely what you need to do...But This may help.

open(LOG, "path/to/logfile.log")|| die "Error: $!";
 
my @text; 

while(<LOG>){
if(/(\[.*\])/g){
push(@text, $1);
}
}
close(LOG);

This guy posted on a number of forums and already has a solution, he will not be coming back here to read your response.

:icon_smile: nice catch Kevin

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.