in reply to Re: Functions in substitutions (s///) and Perl 5.8.
in thread Functions in substitutions (s///) and Perl 5.8.

Grr, that'll teach me to make changes without testing. The substitution needs to have those square brackets escaped:
while (m/\[\[\w+\]\]/) { my $oldpos = pos; m/\[\[(\w+)\]\]/; my $expansion = $helper->($1); pos = $oldpos; s/\[\[$1\]\]/$expansion/; }