p4, the Perl based macro processor. v0.2 When cpp and m4 are insufficient, there is p4. New, with the power of Perl. *ting* p4 has two macro prefix characters $ and &. You can escape these characters with a backslash \ to prevent macro expansion (e.g. \$ and \&). The \ character will be removed in the output. Generally speaking, $ is used for getting values, & is used to eval code. \&() returns a value, where as \&{} does not. There is currently only one builtin macro \&include(). &include("hello.p4") \$who=$who You can define new macro functions. &{ sub who { return $_[0] || $who; } } \&who=&who \&who("me")=&who("me") Hello &who &{$foo = 'bar'} Example of how multiple \ characters are handled for $ and &. \$foo=$foo \\$foo=$foo \\\$foo=$foo You can enclose macros in braces. \${foo}z=${foo}z \&(\$foo)=&($foo) \&(length(\$foo))=&(length($foo)) You can address arrays and hashes. &{@var = ('a','b','c')} \$var[0]=$var[0] \${var[0]}=${var[0]} \&(\$var[0])=&($var[0]) &{ $map{'one'} = 1; $map{'two'} = 2; $map{'2'} = 'two'; $map{'three'} = 3; } \$map{'one'}=$map{'one'} \${map{'two'}}=${map{'two'}} \${map{\$map{'two'}}}=${map{$map{'two'}}} \${map{\$map{'2'}}}=${map{$map{'2'}}} \&(\$map{'three'})=&($map{'three'}) Usage: p4 file.p4 [file2.p4 ...] >output