in reply to write_file to_json in Dancer app

The error message suggests to me that $filename is empty. Maybe you need to initialize it from a different place in your configuration?

Does uploading work if you hardcode the value for $filename instead of using the configuration?

Replies are listed 'Best First'.
Re^2: write_file to_json in Dancer app
by GertMT (Hermit) on Feb 04, 2014 at 16:46 UTC
    aha, yes, thanks. That does work.
    The file is updated if I refresh the browser. Well, with not much I'll have to admit but at least the modification time changes.
    So, I'm not there with the format but I should be able to work that out.
    Thanks!
      updating the code between the comment lines to the code I mention below makes that the data is been written to a 'json' file. Not very clever code yet as the data gets overwritten every time you run the script but that is a separate issue.
      #-------v this does work --------# my $filename = "testme.json"; my $json = -e $filename ? read_file $filename : '{}'; my $data = from_json $json; $data = \@photos; write_file $filename, to_json($data);