[Dancer-users] complex data structures in config.yml

P Kishor punk.kish at gmail.com
Mon Aug 23 22:49:42 CEST 2010


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?


-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================


More information about the Dancer-users mailing list