in reply to Re^2: Using a capture in /(?{...})/
in thread Using a capture in /(?{...})/

The warning comes from the fact that Perl can't tell if (?{ ... }) matches any characters or not, so it's possible you're putting a quantifier on a zero-width assertion.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^4: Using a capture in /(?{...})/
by ikegami (Patriarch) on Jul 26, 2005 at 00:07 UTC

    You mean (??{ ... }). ((?{ ... }) is always zero-width.) Ok, the warning makes sense. There are (at least) two ways of hidding it:

    1) Use no warnings 'regexp', or

    2) refactor the regexp to hide that particular instance of the warning while leaving others on. For example,

    $re0 = qr/ (??{ $re1 })* /x;

    can be written as:

    $re0 = qr/ (??{ $re1 }) (??{ $re0 }) | # Nothing /x;

    and

    $re0 = qr/ (??{ $re1 })+ /x;

    can be written as:

    $re0 = qr/ (??{ $re1 }) (??{ $re0_ }) /x; $re0_ = qr/ (??{ $re1 }) (??{ $re0_ }) | # Nothing /x;

    and

    $re0 = qr/ (??{ $re1 })? /x;

    can be written as:

    $re0 = qr/ (??{ $re1 }) | # Nothing /x;