use YAML::Syck; # Set this for interoperability with other YAML/Syck bindings: # e.g. Load('Yes') becomes 1 and Load('No') becomes ''. $YAML::Syck::ImplicitTyping = 1; $data = Load($yaml); $yaml = Dump($data); # $file can be an IO object, or a filename $data = LoadFile($file); DumpFile($file, $data); # A string with multiple YAML streams in it $yaml = Dump(@data); @data = Load($yaml); # Dumping into a pre-existing output buffer my $yaml; DumpInto(\$yaml, @data);
NOTE: If you are working with other language's YAML/Syck bindings (such as Ruby), please set $YAML::Syck::ImplicitTyping to 1 before calling the "Load"/"Dump" functions. The default setting is for preserving backward-compatibility with "YAML.pm".
Regardless of this flag, Unicode strings are dumped verbatim without escaping; byte strings with high-bit set will be dumped with backslash escaping.
However, because YAML does not distinguish between these two kinds of strings, so this flag will affect loading of both variants of strings.
If you want to use LoadFile or DumpFile with unicode, you are required to open your own file in order to assure it's UTF8 encoded:
open(my $fh, ">:encoding(UTF-8)", "out.yml"); DumpFile($fh, $hashref);
Setting $YAML::Syck::UseCode to a true value is equivalent to setting both $YAML::Syck::LoadCode and $YAML::Syck::DumpCode to true.
You can create any kind of object with YAML. The creation itself is not the critical part. If the class has a DESTROY method, it will be called once the object is deleted. An example with File::Temp removing files can be found at <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862373>
Dumping of Tied variables is unsupported.
Dumping into tied (or other magic variables) with "DumpInto" might not work properly in all cases.
The current implementation bundles libsyck source code; if your system has a site-wide shared libsyck, it will not be used.
Tag names such as "!!perl/hash:Foo" is blessed into the package "Foo", but the "!hs/foo" and "!!hs/Foo" tags are blessed into "hs::Foo". Note that this holds true even if the tag contains non-word characters; for example, "!haskell.org/Foo" is blessed into "haskell.org::Foo". Please use Class::Rebless to cast it into other user-defined packages. You can also set the LoadBlessed flag false to disable all blessing.
This module has a lot of known issues <https://rt.cpan.org/Public/Dist/Display.html?Name=YAML-Syck> and has only been semi-actively maintained since 2007. If you encounter an issue with it probably won't be fixed unless you offer up a patch <http://github.com/toddr/YAML-Syck> in Git that's ready for release.
There are still good reasons to use this module, such as better interoperability with other syck wrappers (like Ruby's), or some edge case of YAML's syntax that it handles better. It'll probably work perfectly for you, but if it doesn't you may want to look at YAML::XS, or perhaps at looking another serialization format like JSON.
This software is released under the MIT license cited below.
The libsyck code bundled with this library is released by ``why the lucky stiff'', under a BSD-style license. See the COPYING file for details.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.