Reputation: 11320
Simple question: Is there a way that I can create a constant string inside a perl mason file? I want to be able to assign a hard coded string to a variable at the top of my perl file and then be able to use it throughout the rest of the file. Something the equivalent of Java's
private static final String DEFAULT_USERNAME = "Bobby Joe";
Upvotes: 2
Views: 1004
Reputation: 118605
An equivalent concept in Perl is the constant
pragma:
% use constant DEFAULT_USERNAME => "Bobby Joe";
<h1>Welcome, <% DEFAULT_USERNAME %></h1>
This is syntactic sugar that actually creates a subroutine called DEFAULT_USERNAME
in the current package, as if you said
sub DEFAULT_USERNAME () { "Bobby Joe" }
Upvotes: 3