I have a input txt file containing multiple number of lines in the mentioned format.
JMOD_01 :: This is starting of grouping 2nd KFGJHFG RTIRT DFB SFJKF ERIEFF FJDKF OIOIISD SDJKD
last line ______________ 5564 numerical digits.
This is second starting of grouping 2nd KFGJHFG RTIRT FSFJKF
ERIEFF FJDKF OIOIISD SDJKD
till this end ___________ 021542 some random digits.
I am trying to read this file and extract the searched pattern in a grouping manner
This is below, what I have tried. I tried, grouping the first match and it is getting captured properly. Issue is coming while looking for second grouping as , it is not considering the next line elements.
open(IFH,'<',"file.txt");
while ($line = <IFH>) {
if ($line =~ /^\s*(\w+\_\d*.*)\s*::(.*)/s) {
print "$1\n";
print "$2\n";
}
}
close(IFH);
Expected result :
print $1; #This should give me
JMOD_01
fdgh_6765_546/456
and when , print $2; #then it should give me
"This is starting of grouping 2nd KFGJHFG RTIRT DFB SFJKF ERIEFF FJDKF OIOIISD SDJKD last line"
"This is second starting of grouping 2nd KFGJHFG RTIRT FSFJKF
ERIEFF FJDKF OIOIISD SDJKD till this end"
and when, print $3; #then it should give
"5564 numerical digits"
"021542 some random digits"
But actual output is coming different for 2nd grouping : print $2; #actual output
"This is first starting of grouping 2nd KFGJHFG RTIRT DFB SFJKF"
"This is second starting of grouping 2nd KFGJHFG RTIRT FSFJKF"
