Skip to content

Instantly share code, notes, and snippets.

@Code-Hex
Created August 22, 2014 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Code-Hex/bae1c83a7648b85a066e to your computer and use it in GitHub Desktop.
Save Code-Hex/bae1c83a7648b85a066e to your computer and use it in GitHub Desktop.
YAML 上書き保存方法
use strict;
use YAML::XS;
my %h = ("12" => 4);
$h{foo} = "bar";
my @array = qw/apple banana orange/;
## YAMLドキュメントの読み込み
my $filename = YAML::XS::Load("example.yaml");
open F, '>>', $filename or die("cannot open file.");
print F Dump \%h; #YAMLでハッシュとして扱える
print F Dump %h; #おかしなこと
print F Dump \@array; #YAMLで配列として扱える
print F Dump @array; #おかしなこと
close F;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment