I have been able to use flip-flop to extract text in past where I have different START & END.
This time I've been having A LOT of trouble trying to extract text because I do not have different delimiters in my source file, because START & END of flip flop are the same. I want flip flop to start true when line beings with year yyyy & continue to push $_
to an array until another line begins yyyy.
The problem with flip-flop is that it will then be false on my next START.
while (<SOURCEFILE>) {
print if (/^2017/ ... /^2017/)
}
Using the above for the given source data will miss the 2nd multi-line part of the file I also need to match. Maybe flip-flop which I thought was the best way to parse a multi line file will not work in this case? What I want to do is start matching with the first line starting with date & continue matching until the line before the next line beginning with a date.
Sample Data is:
2017 message 1
Text
Text
Text
2017 message 2
more text
more text
more text
2017 message 3
yet more text
yet more text
yet more text
But I am getting:
2017 message 1
Text
Text
Text
2017 message 2
2017 message 3
yet more text
yet more text
yet more text
...missing message 2 contents..
I cannot rely on space or a different END delimiter in my source data.
What I wanted was for each message to be printed (actually push @myarray, $_
& then test for matches), but here I am missing lines below message 2 because flip flop is set to false. Any way to handle this with flip-flop or I need to use something else?
Thanks in advance for anyone that can help/advise.