in reply to pattern detection inside until loop in perl
You have 2 ways to exit the loop:
I would simplify to one condition. Note null string is "false". Also $gotit doesn't appear to be necessary because it appears that the lookfor() method is looking for what you told it to with the are_match() method.- until ("" ne $gotit) - if($gotit){last;}
unless and until can sometimes confuse folks, so I tend to prefer using "while" for the vast majority of my loops like this.$PortObj->are_match("abcd"); # Pattern to match send_prompt(); #I presume this happens? while (!$PortObj->lookfor() ) { print("Pattern is not detected\n"); send_prompt(); #re-prompt } # pattern is detected here ... we continue
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pattern detection inside until loop in perl
by vrushali (Initiate) on Dec 16, 2010 at 13:22 UTC | |
by Marshall (Canon) on Dec 19, 2010 at 06:09 UTC |