【发布时间】:2019-07-12 17:45:30
【问题描述】:
是否可以编写向调用者返回哈希的宏或块?
我尝试将一些模板代码模块化:
[%-
MACRO MakeSomeThing(something) BLOCK;
s = { a => 'a',
b => something,
c => 'c'
};
# RETURN s; # not allowed
# s; # just returns the hash ref string (HASH(0x32e42e4))
END;
newOb = MakeSomeThing('foo');
dumper.dump({'newOb' => newOb});
%]
有没有办法实现类似的模式?
【问题讨论】:
标签: perl template-toolkit