Is it possible to assign value to a global variable in handler.pl
?
I need to assign a value to a global variable in handler.pl
, and get the value from a Mason component.
I tried this way:
httpd.conf
...
PerlRequire handler.pl
...
handler.pl
...
our $x = 'test';
...
something.mas
...
<h1><% $x %></h1>
...
but it is not working, it doesn't return <h1>test</h1>
but just <h1></h1>
as $x
is undefined. How can I make it work?
Yes, but you'll have to set
in httpd.conf, or in handler.pl include
in your apache handler definition, or declare it in the HTML::Mason::Commands package that the components run in:
This last option is also how you can make other Perl modules available in all components:
Refer to http://www.masonhq.com/?FAQ:Components#h-can_i_use_globals_in_components_