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!
To access such a global variable here is the right syntax:
say $my_app::GLOBAL_VAR;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With