On Mon, Aug 23, 2010 at 3:49 PM, P Kishor <punk.kish@gmail.com> wrote:
I am trying to unsuccessfully move a couple of complex data structures to config.yml
For example, I have the following in my Perl script
@models = ( {id => 1, name => "Low carbon", palette => "black_blue", year => 1900}, {id => 2, name => "Low nitrogen", palette => "red_green", year => 1900}, {id => 3, name => "High water", palette => "yellow_red", year => 1900} );
As far as I can tell, I can convert it to YAML like so
models: - model_id: 1 name: "Low carbon" palette: "black_blue" start_year: 1900 - model_id: 2 name: "Low nitrogen" palette: "red_green" start_year: 1900 - model_id: 3 name: "High water" palette: "yellow_red" start_year: 1900
and then, in my Dancer code, I should be able to do
my @models = config->{models};
or at least
my $models = config->{models};
(I am not sure if I should get an array or an arrayref).
In any case, I get the following error
Error while loading /Users/punkish/Sites/app/app.psgi: YAML Error: Stream does not end with newline character\n Code: YAML_PARSE_ERR_NO_FINAL_NEWLINE\n
Needless to say, I do have a final newline, so the error is misleading. What am I doing wrong? What can I do right?
Never mind.. it was user-error. There was a funky, invisible char in my yaml file. It all works now. And, fwiw, config->{models} returns an arrayref. Puneet.