s/(\w+)(?(?{ !$d{$1} })(?!))/$d{$1}->($1)/ge;
Your solution fails if the non-existant word is followed by a one ("1"). For example, try input "baz1".
In reply to Re^2: Check exist of anonymous subroutine before calling it within regexp substitute?
by ikegami
in thread Check exist of anonymous subroutine before calling it within regexp substitute?
by jffry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |