srchulo srchulo - 1 year ago 83
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
like so:

our $GLOBAL_VAR = 'value';

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


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 Source

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

say $my_app::GLOBAL_VAR;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download