in reply to Regex to add text if text is missing
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.$_ = 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;
|
|---|