perl template 模板学习(一)
时间:2008-06-25 来源:sohu2000000
process($input, \%replace)
The process() method is called to process a template specified as the first parameter, $input. This may be a file name, file handle (e.g. GLOB or IO::Handle) or a reference to a text string containing the template text. An additional hash reference may be passed containing template variable definitions.
The method processes the template, adding any PRE_PROCESS or POST_PROCESS templates defined, and returns the output text. An uncaught exception thrown by the template will be handled by a relevant ERROR handler if defined. Errors that occur in the PRE_PROCESS or POST_PROCESS templates, or those that occur in the main input template and aren't handled, cause the method to return undef to indicate failure. The appropriate error message can be retrieved(取回, 挽回, 弥补, 恢复, 补偿, 回忆, 检索) via the error() method.
$service->process('myfile.html', { title => 'My Test File' })
|| die $service->error();