No such thing as a small change | |
PerlMonks |
Good practice for OO module defaultsby davies (Prior) |
on Apr 08, 2019 at 09:35 UTC ( [id://1232282]=perlquestion: print w/replies, xml ) | Need Help?? |
davies has asked for the wisdom of the Perl Monks concerning the following question: I am writing a module using Moo. I want the object to have some defaults if values are not specified at creation. Some of the strings are quite long and it is conceivable that they may change. A config file is possible, but that would mean enforcing a directory structure on every machine, Windows or *u*x, which does not appeal to me. I therefore planned to use __DATA__ to hold the strings. There are plenty of warnings on this site not to use __DATA__ in production. Also, it causes problems. If I create two objects, the second comes without the defaults because __DATA__ has already been read. The options as I see them are:
I am minded to use the fourth of these, but would like to know the Monasteriat's recommendations. Regards, John Davies
Back to
Seekers of Perl Wisdom
|
|