use Text::MicroMason; $interpreter = Text::MicroMason->new( -TextTemplate ); $template = "bar { $var1 } foo { $var2 } bar BAAAR!"; $subroutine = $interpreter->compile( $template ); $output = $subroutine->( var1=>"Guybrush", var2=>"Purcell" );