YAML でハッシュ内の配列を読む
サンプル
#!/usr/bin/perl use strict; use warnings; use utf8; use YAML::Syck; # 読込用 YAML データの準備 my $yaml = <<'END'; names: - Linux - FreeBSD - Mac OS X - Windows - OpenBSD END # YAML データをパースする my $configs = YAML::Syck::Load($yaml); # 配列部分のデリファレンスを行う for (@{$configs->{names}}) { print $_, "\n"; }
実行結果
% ./array_in_hash_with_yaml.pl Linux FreeBSD Mac OS X Windows OpenBSD