in reply to Executing a function within a regex

You need the /e (for evaluate) option on your substitution, so the function will be called instead of having its name interpolated:

$test =~ s/(\w)(\w+)(\w)/$1 . &garble($2) . $3/eg;



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders