Hi, All Is there any good way to change config.yml from code, and save it to file? like use Dancer::Config 'setting'; ? Thanks Simon
On Wed, 2011-01-19 at 17:38 +0800, yang xm wrote:
Is there any good way to change config.yml from code, and save it to file? like use Dancer::Config 'setting'; ?
You mean to modify settings at runtime, then write them back to the config.yml file? Dancer doesn't provide any facility to do that (it's not something I'd imagine many people would need to do, nor something I'd encourage), but you could roll your own quite simply with something along the lines of: my $yaml = to_yaml(config()); open (my $configfh, '>', Dancer::FileUtils::path(setting->{confdir}, 'config.yml') ) or die "Failed to open config file to write - $!"; print $fh $yaml; close $fh; You could easily write this as a plugin to release to CPAN (e.g. Dancer::Plugin::UpdateConfig, or something). Cheers Dave P -- David Precious <davidp@preshweb.co.uk> ("bigpresh") http://www.preshweb.co.uk/
participants (2)
-
David Precious -
yang xm