[Catalyst] best practice: where to put constants

Jarom Smith jarom at jaromsmith.net
Thu Jun 4 15:55:34 GMT 2009


I thought about putting constants in $c->config, but decided not to 
mostly because it would allow a malicious (or ignorant) user to 
completely screw up my app.  A constant should be, uh... constant!

I have been resisting learning YAML, mostly because I am learning so 
many new things right now that I don't want to add one more thing to the 
list... but I know I will have to dig in eventually.

jarom smith
tech go-to guy


Alejandro Imass wrote:
> Although I think there is no best practice as such, I mean there are
> many ways to do this in Perl in general, but Catalyst offers the nice
> feature of the main config file in YAML, so I keep all my constants
> and configuration values there.
> 
> YAML is so powerful that IMHO it's the best place not ony to store
> your constants but to structure them intelligently. Of course, all the
> constants you put in your YAML file will be vailable through
> $c->config->{foo}
> 
> Best,
> Alejandro Imass
> 
>



More information about the Catalyst mailing list