I won't claim to clearly understand what you are doing but it looks like using (?{...}) is an overly complex way to go here. Something much simpler might work for you:
s/(...)/ func( $1 ) || $1 /ge; s/(\[(...)\])/ func( $2 ) || $1 /ge; s/(\[(...)\])/ my $ret= func( $2 ); defined $ret ? "[$ret]" : $1 /ge; s/(\[(...)\])/ my @ret= func( $2 ); @ret ? "[@ret]" : $1; /ge;
- tye
In reply to Re^3: Regex (?{ code }) and use re 'eval' (KISS)
by tye
in thread Regex (?{ code }) and use re 'eval'
by SFLEX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |