Problems? Is your data what you think it is? | |
PerlMonks |
Flip-flop reset?by swkronenfeld (Hermit) |
on Aug 29, 2006 at 19:41 UTC ( [id://570232]=perlquestion: print w/replies, xml ) | Need Help?? |
swkronenfeld has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way to reset a flip-flop operator? For example, I have the following text that I am searching for, in which I am scanning for processes which have a ':D' appended to the back of the :\d:\d (i.e. :0:0:D). There are a number of lines above the lines that I show, however there are no lines below.
Here's my code, This works fine the first time through. However, sometimes my flop never evaluates to true, because there is not a blank line at the end of my output. Since the flop will never evaluate to true, the next time I run mySub the operator will be in the true state. Of course, I can just keep track of the state in a scalar rather than using the flip-flop operator, or I could do some kind of @arr manipulation. But I'm figuring that there is a Perl way of solving this problem that I'm not aware of. Any input is appreciated. Some further clarification on the text I'm processing: -sometimes there will be a final line with a newline, sometimes the last line shown there is the last line of input -The number of lines of processes is unknown, and does not have any "keyword" that I'm aware of. Update: The match is looking for :\d:\d, not :0:0, thanks to aartisesha for pointing out the error in my question.
Back to
Seekers of Perl Wisdom
|
|