#-------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);