use Filter::m4;
use Filter::m4 'prefix';
As with all source filters its scope is limited to the current source file only. Every file you want to be processed by the filter must have the following line near the top.
use Filter::m4;
use Filter::m4;
define(`foo', `$1 =~ s/bar/baz/r')
$a = "foobar";
print "a = " . foo(`$a') . "\n";
The output of the above example:
a = foobaz
M4 uses $1, $2, etc., to indicate arguments in macros. To avoid clashes with Perl regex syntax it is recommended to use Perl's alternative forms "${1}", "${1}", etc.
The following keywords in M4 and Perl are identical:
eval
format
index
mkstemp
shift
substr
If you need such keywords in your Perl code you have to use one of the following three solutions.