Re: how to run regex calculation
demerphq <[email protected]>
| Newsgroups | gmane.comp.apache.mod-perl |
|---|---|
| Message-ID | <CANgJU+XNpxPbv86hjFgzZtGYeaKMXu7jrWciuPQpfahAAJ7T5w@mail.gmail.com> |
On Thu, 9 Jan 2020 at 05:49, Joseph He <[email protected]> wrote: > > I think $str =~ /(\d+)\s(\d+)\s(??{$1*$2})/ should do it > My Perl version is v5.26.1 I think you mean (??{ "$1*$2"}) which might work, but it will be error prone, (??{"(?$1)*$2") would be better, but both will be slow, as each time a new pattern willbe compiled. /(\d+)\s(\d+)\s(\1*\2)/ just works, and does not recompile the pattern over and over. Look for "back references" in perlre. Yves