On Thu, 9 Jan 2020 at 17:25, MIchael Capone <mcap...@cablewholesale.com> wrote:
>
> It probably won't ever work.

Joseph He's solution works just fine:

perl -le'for my $str ("2 3 6", "1 1 1" ,"1 2 3","123 456 56088"){
print "($str)", $str =~ /(\d+)\s(\d+)\s(??{ $1 * $2 })/ ? " matched" :
" rejected"}'
(2 3 6) matched
(1 1 1) matched
(1 2 3) rejected
(123 456 56088) matched

(??{ ... }) is the recursive/deferred pattern,  it executes code and
then uses the final result as a new pattern that must match at the
current position in the string.

Yves

Yves

Reply via email to