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

Discussion in 'Perl Misc' started by gb345, Oct 5, 2009.

  1. gb345

    gb345 Guest

    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
     
    gb345, Oct 5, 2009
    #1
    1. Advertising

  2. gb345

    gb345 Guest

    In <> Ben Morrow <> writes:

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


    Thanks.

    G.
     
    gb345, Oct 5, 2009
    #2
    1. Advertising

  3. gb345

    Guest

    On Mon, 5 Oct 2009 14:50:07 +0000 (UTC), gb345 <> 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
     
    , Oct 5, 2009
    #3
  4. On 2009-10-05, gb345 <> wrote:
    > In <> Ben Morrow
    > <> 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
     
    Eric Pozharski, Oct 6, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    723
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,649
    Ant...
    Nov 6, 2003
  3. Replies:
    3
    Views:
    794
    Reedick, Andrew
    Jul 1, 2008
  4. Replies:
    3
    Views:
    166
    Paul Lalli
    Oct 27, 2005
  5. ccc31807
    Replies:
    8
    Views:
    480
    ccc31807
    Oct 6, 2009
Loading...

Share This Page