Created
August 22, 2014 02:18
-
-
Save Code-Hex/bae1c83a7648b85a066e to your computer and use it in GitHub Desktop.
YAML 上書き保存方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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