Hi Alexey,
Your solution looks correct.
The notes for perl584delta(1) are not strictly correct, it should say something like:
my $x = qr{ ... (??{ $x }) ... };
will now (correctly) fail under use strict. (As the inner $x is and has
always referred to the package variable $x, not the lexical variable $x)
I guess the author of that note was assuming that the code was written in the 'main' package.
The reason your patch is necessary is similar to the reason each of the following lines will fail: the right side of the assignment always refers to the *old* value of the variable, and that variable hasn't been declared yet, so it bombs under 'strict' syntax rules.
use strict; my $x = $x + 1; our $y = $y + 2;
-Ken
On May 15, 2004, at 12:54 PM, Alexey Tourbin wrote:
Hi, And thanks for perl-5.8.4.
I've got a problem with Inline-0.44, which got a bit broken with perl-5.8.4 because of /??{...}/ related changes.
$ perl5.8.4 -c Inline-0.44/C/lib/Inline/C/ParseRegExp.pm-
Variable "$RE_balanced_brackets" is not imported at (re_eval 1) line 2.
Global symbol "$RE_balanced_brackets" requires explicit package name at (re_eval 1) line 2.
Compilation failed in regexp at Inline-0.44/C/lib/Inline/C/ParseRegExp.pm- line 25.
$ perl5.8.4 -c Inline-0.44/C/lib/Inline/C/ParseRegExp.pm
Inline-0.44/C/lib/Inline/C/ParseRegExp.pm syntax OK
$
So the following patch seems to solve the problem.
--- Inline-0.44/C/lib/Inline/C/ParseRegExp.pm- 2002-11-04 21:39:52 +0000
+++ Inline-0.44/C/lib/Inline/C/ParseRegExp.pm 2004-05-15 17:14:19 +0000
@@ -21,9 +21,9 @@ sub code {
my $RE_comment_Cpp = q{(?:\/\*(?:(?!\*\/)[\s\S])*\*\/|\/\/[^\n]*\n)};
my $RE_quoted = (q{(?:(?:\")(?:[^\\\"]*(?:\\.[^\\\"]*)*)(?:\")}
.q{|(?:\')(?:[^\\\']*(?:\\.[^\\\']*)*)(?:\'))});
- our $RE_balanced_brackets =
+ our $RE_balanced_brackets; $RE_balanced_brackets =
qr'(?:[{]((?:(?>[^{}]+)|(??{$RE_balanced_brackets}))*)[}])';
- our $RE_balanced_parens =
+ our $RE_balanced_parens; $RE_balanced_parens =
qr'(?:[(]((?:(?>[^()]+)|(??{$RE_balanced_parens}))*)[)])';
# First, we crush out anything potentially confusing. End of patch
Things are a bit unclear to me, though. perl584delta(1) says:
my $x = qr{ ... (??{ $x }) ... };
will now (correctly) fail under use strict. (As the inner $x is and has
always referred to $::x)
And according to perlfunc(1), $::x is always equivalent to $main::x. On the other hand, `our $x' declaration is known to create lexically scoped alias to the global variable $x in the current package.
So, back to Inline-0.44,
`our $RE_balanced_brackets' refers to $Inline::C::ParseRegExp::RE_balanced_brackets,
/??{$RE_balanced_brackets}/ refers to $main::RE_balanced_brackets.
So does this patch really fixes anything? Why does syntax check pass then? Did I get something wrong?
-- Alexey Tourbin ALT Linux Team