Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
简单的问题:有没有办法可以在 perl mason 文件中创建一个常量字符串?我希望能够将硬编码字符串分配给我的 perl 文件顶部的变量,然后能够在文件的其余部分中使用它。相当于Java的东西
private static final String DEFAULT_USERNAME = "Bobby Joe";
Perl 中的一个等效概念是constantpragma:
constant
% use constant DEFAULT_USERNAME => "Bobby Joe"; <h1>Welcome, <% DEFAULT_USERNAME %></h1>
这是语法糖,它实际上创建了一个DEFAULT_USERNAME在当前包中调用的子例程,就像你说的那样
DEFAULT_USERNAME
sub DEFAULT_USERNAME () { "Bobby Joe" }