in reply to Regex to add text if text is missing

I imagine there's a more efficient way to do this with backwards or forwards looking, but I'm not that good at regex. The following works, even if it does more substitutions than are necessary:
$_ = join '', <DATA>; # Add & to front of function calls without. s/&?(\w+\(.*?\))/&$1/g; # Add () to end of function calls without. s/(&\w+)(?:\((.*?)\))?/$1($2)/g; print; __DATA__ &somesub('args'); somesub('args'); &somesub;
This way of doing things may have problems, however. You will end up not only replacing sub calls, but built-in function calls as well. You need to add a sub to check function names against a Perl function list, and add that to the regex with an e flag.