From: Atul P. <atu...@ya...> - 2009-12-11 12:49:18
|
folks, I'm trying to put together a regex, but failing to see how I can do it correctly. The string being returned & captured is of the style, :Q0615000000050000001200000005000000 From the command I send, I know the first four characters will be " :Q06 " , so I'm using the following the following expect to capture the returned string. $k->clear_accum(); $k->send_slow(1, "$command Q06"); $k->expect(5, ":Q06"); $query_value = $k->after(); However, every so often there appears to be a race condition. The match for :Q06 occurs, but the string $k->after() manages to run before the rest of the digits have been returned. I inserted a "sleep 1; " before the $k->after(); this appears to work, but I'd rathernot start introducing sleeps into the code. I tried the following to be more explicit; $k->expect(5, '-re', qr/^:Q06.*$/); # match all characters to the end of the line $query_value = $k->match(); # and grab the match but this didn't work either, so I'm confused why this behaved in the same way; I know exactly how many characters expect in the match but not sure how to use this to match the entire string? any help, pointers would be appreciated! atts. |