in reply to all matches

Eval-group not allowed at runtime, use re 'eval' in regex m/ a(.)*a(?{ +push @substrings, $^N}) (?!) /
The ?{} construct evaluates perl code inside a regular expression. By default it's off, so you want to do use re 'eval' to turn it on.

Replies are listed 'Best First'.
Re: Re: all matches
by jweed (Chaplain) on Mar 25, 2004 at 05:51 UTC
    To clarify, (?{}) constructs can be used without the use re 'eval' pragma, but only if the regex contains no elements interpolated from variables. Perhaps an example is called for:
    #fine /a (.*) a(.)*(?{push @substrings, $^N}) (?!)/ #not fine: we get part of the regex body from a variable /$regex(?{push @substrings, $^N}) (?!)/ ^^^^^^ this variable interpolation requires that you use re 'eval'
    Type perldoc re at your command prompt for more info.



    Code is (almost) always untested.
    http://www.justicepoetic.net/
      Thanks for the replies:)I checked the perldoc re and and it solved the eval problem but still although there is correct number of match in the array they are all undefined. I would appreciate any help? thanks