srchulo srchulo - 21 days ago 7
Perl Question

catalyst application-wide variable

I would like to be able to define an application-wide (global) variable in my Catalyst application so that I can access it in any controller I am in. The purpose for this is that I'm not repeating values around my app that for the most part never change. Currently I am defining variables in

my_app.pm
like so:

our $GLOBAL_VAR = 'value';


And then in my controllers, I try to access the variable just like I would a subroutine:

my_app::$GLOBAL_VAR


However, this does not work. Does anyone know the best way to do this, or a better way to achieve this in Catalyst? Thanks!

Answer

To access such a global variable here is the right syntax:

say $my_app::GLOBAL_VAR;

Regards,

Comments