paxxus
October 28th, 2012, 12:20 AM
Hi, I'm really struggling with this.
This perl program successfully parses past the blank lines and comments:
$s = <<END;
// Hello
// World
xxx
END
$s =~ m,\G((//.*)?\s*)*,mgc;
print ">", $s, "<\n";
print ">", substr( $s, pos( $s ) ), "<\n";
As expected it parses to the 'xxx' and the output is:
>
// Hello
// World
xxx
<
>xxx
<
However, if I change the regexp to:
$s =~ m,\G(\s*|//.*)*,mgc;
It only parses the first blank line :confused:
The non-functional regexp simply says that it should match zero or more sequences of white-space or line-comments, but it doesn't work for some reason, and I'd like to know why.
This perl program successfully parses past the blank lines and comments:
$s = <<END;
// Hello
// World
xxx
END
$s =~ m,\G((//.*)?\s*)*,mgc;
print ">", $s, "<\n";
print ">", substr( $s, pos( $s ) ), "<\n";
As expected it parses to the 'xxx' and the output is:
>
// Hello
// World
xxx
<
>xxx
<
However, if I change the regexp to:
$s =~ m,\G(\s*|//.*)*,mgc;
It only parses the first blank line :confused:
The non-functional regexp simply says that it should match zero or more sequences of white-space or line-comments, but it doesn't work for some reason, and I'd like to know why.