From: Joe C. <jc...@un...> - 2003-04-21 15:04:22
|
Hi, This simple program fails because of the brackets in the data: %data = ('test [1]' => 1); $yaml = YAML::Dump(\%data); $data = YAML::Load($yaml); The dump doesn't quote the string "test [1]", which causes the load to get this error: --- !perl/YAML::Error code: YAML_LOAD_ERR_BAD_MAP_ELEMENT msg: Invalid element in map line: 2 document: 1 ... (I'm using version 0.35.) I find it hard to believe that yaml handles all sorts of complicated data types but can't handle brackets in strings. Has anyone else run into this problem? I think I found a way to fix it but I'm not sure if it will break anything else. In sub is_valid_implicit in yaml.pm, I commented out this line: return 1 if $_[0] =~ /^\w/; # !str and I added this line: return 0 if $_[0] =~ /\W/; So any string containing punctuation or spaces will be quoted by sub _emit_str. Any feedback on the problem or on my fix would be appreciated. Thanks. -Joe |