C
Clint Olsen
Hi:
I'm currently using 5.8.1, and I'm writing a lexer which operates on a
scalar that has the contents of the entire file. I'm using the usual
suspects (/gc and \G) in all of my patterns to remember where I was.
However, I've noticed a technique in Parse::Yapp which does the following:
LOOP: for ($scalar) {
/whitespace/ and next LOOP;
/pattern/ and this;
/patern1/ and that;
}
What exactly is the for() loop doing that's different than $_ = $scalar?
The documentation is pretty scant on this subject - conditions under which
pos() will be reset. Generally a for loop consists of an initialization, a
test, and an optional chunk to do at the end of the code BLOCK.
Thanks,
-Clint
I'm currently using 5.8.1, and I'm writing a lexer which operates on a
scalar that has the contents of the entire file. I'm using the usual
suspects (/gc and \G) in all of my patterns to remember where I was.
However, I've noticed a technique in Parse::Yapp which does the following:
LOOP: for ($scalar) {
/whitespace/ and next LOOP;
/pattern/ and this;
/patern1/ and that;
}
What exactly is the for() loop doing that's different than $_ = $scalar?
The documentation is pretty scant on this subject - conditions under which
pos() will be reset. Generally a for loop consists of an initialization, a
test, and an optional chunk to do at the end of the code BLOCK.
Thanks,
-Clint