How to capture specific strings from a file and dump it to diff file in perl -


i have log file contains results of various test conditions. looks like

starting testcon1 msg1:criteria result:pass msg2:criteria result:fail  starting testcon2 msg1:criteria result:fail msg2:criteria result:pass  starting testcon3 msg1:criteria result:pass 

i want create subroutine picks out "msg have failed along testcon belong to.this dumped summary file showing--> msg failed ,the result , testcon belongs to

i have no clue start ,can give me idea start with

read file, use regex , variables.

#!/usr/bin/env perl $testcon; $msg; while (<stdin>) {     if (/^starting (.+)$/) { $testcon = $1 }     elsif (/^msg(\d+:\s*.+)$/) { $msg = $1 }     elsif (/^result:\s*fail$/) { print "$testcon\t$msg\n" } } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -