Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > regex bug: "variable ... will not stay shared"

Reply
Thread Tools

regex bug: "variable ... will not stay shared"

 
 
gb345
Guest
Posts: n/a
 
      10-05-2009




Some code that used to work fine with perl 5.8.8 now generates a
warning when I run it with perl 5.10.0. The error is caused by a
recursive regex that is supposed to match a balanced expression.
This regex is defined using qr//, and is assigned to the variable
$pex, and mentions this variable in its definition.

The warning message is:

Variable "$pex" will not stay shared at (re_eval 5) line 2.
Variable "$pex" will not stay shared at (re_eval 6) line 2.

Here's the beast:

my $pex;
$pex = qr/
\{
(?:
(?:
"
( (?> (?:[^"\\]|\\[^"])* ) (?> \\" (?:[^"\\]|\\[^"])* )* )
"
|
(?!\{) ( [^",]* ) (?<!\})
|
(??{ $pex })
)
(?:
,
(?:
"
( (?> (?:[^"\\]|\\[^"])* ) (?> \\" (?:[^"\\]|\\[^"])* )* )
"
|
(?!\{) ( [^",]* ) (?<!\})
|
(??{ $pex })
)
)*
)?
\}
/x;

I want to fix whatever it is that the warning is warning about
(rather than simply turn off the warning), but it's not clear to
me exactly what the problem is (especially since this code has been
performing flawlessly up to now).

Any clarifications of what the error message is actually saying,
or suggestions to fix the problem would be much appreciated.

Many thanks in advance!

Gabe
 
Reply With Quote
 
 
 
 
gb345
Guest
Posts: n/a
 
      10-05-2009
In <(E-Mail Removed)> Ben Morrow <(E-Mail Removed)> writes:

>The workaround is to use 'our' variables instead.


Thanks.

G.
 
Reply With Quote
 
 
 
 
sln@netherlands.com
Guest
Posts: n/a
 
      10-05-2009
On Mon, 5 Oct 2009 14:50:07 +0000 (UTC), gb345 <(E-Mail Removed)> wrote:

>
>
>
>
>Some code that used to work fine with perl 5.8.8 now generates a
>warning when I run it with perl 5.10.0. The error is caused by a
>recursive regex that is supposed to match a balanced expression.
>This regex is defined using qr//, and is assigned to the variable
>$pex, and mentions this variable in its definition.
>
>The warning message is:
>
>Variable "$pex" will not stay shared at (re_eval 5) line 2.
>Variable "$pex" will not stay shared at (re_eval 6) line 2.
>

<snip>
>
>I want to fix whatever it is that the warning is warning about
>(rather than simply turn off the warning), but it's not clear to
>me exactly what the problem is (especially since this code has been
>performing flawlessly up to now).
>
>Any clarifications of what the error message is actually saying,
>or suggestions to fix the problem would be much appreciated.
>
>Many thanks in advance!
>
>Gabe


I don't get that message on my 5.10.0 multi-threaded x86 build
(although seen it before). Its probably the usage, certain parts
were untouched.

Can you post a sample usage that generates the warning.

Also, I don't see how this matches balanced text/expression.
It doesen't on my sample. Maybe you could describe what it is
you are trying to get with it. Are you trying to capture?

-sln
 
Reply With Quote
 
Eric Pozharski
Guest
Posts: n/a
 
      10-06-2009
On 2009-10-05, gb345 <(E-Mail Removed)> wrote:
> In <(E-Mail Removed)> Ben Morrow
> <(E-Mail Removed)> writes:
>
>>The workaround is to use 'our' variables instead.

>
> Thanks.


And your regex smells like "parsing HTML with regexes" (it's not but it
smells). Consider making regular parser.


--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
Wireless Zero Configuration does not stay started =?Utf-8?B?Sm9l?= Wireless Networking 1 09-30-2006 10:15 PM
regex bug (comments within regex not as robust) kg.google@olympiakos.com Perl Misc 3 10-27-2005 07:21 PM
FAVORITES will not stay in order radiosigs Computer Support 1 07-06-2005 08:33 PM
Cisco VPN client will not stay connected. Help please. Sue Cisco 4 01-07-2004 09:35 AM



Advertisments