「Text::FrontMatter::YAML」の版間の差分
提供: dsk's note
細 |
細 |
||
(同じ利用者による、間の6版が非表示) | |||
1行目: | 1行目: | ||
+ | {{google/ad/01}} | ||
+ | |||
<syntaxhighlight lang="perl"> | <syntaxhighlight lang="perl"> | ||
#!/usr/bin/perl | #!/usr/bin/perl | ||
13行目: | 15行目: | ||
my $metadata = $tfm->frontmatter_hashref; | my $metadata = $tfm->frontmatter_hashref; | ||
− | print qq(This is $metadata->{title} | + | print qq(This is $metadata->{title}\n); |
+ | print qq(This is $metadata->{date}\n); | ||
+ | print qq(This is $metadata->{taxonomy}->{category}\n); | ||
+ | print qq(This is $metadata->{taxonomy}->{tag}\n); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
25行目: | 30行目: | ||
--- | --- | ||
</pre> | </pre> | ||
+ | |||
+ | ===正規表現=== | ||
+ | *$yf =~/^-{3}${1}(.*?)-{3}${1}/#Triple-dashedを含まない | ||
+ | *$yf =~/^(-{3}${1}.*?-{3})${1}/#Triple-dashedを含む | ||
[[Category: perl]] | [[Category: perl]] | ||
+ | |||
+ | {{google/ad/01}} |
2016年4月21日 (木) 16:40時点における最新版
#!/usr/bin/perl use File::Slurp; use Text::FrontMatter::YAML; # READING my $text_with_frontmatter = read_file("item.md"); my $tfm = Text::FrontMatter::YAML->new( document_string => $text_with_frontmatter ); my $metadata = $tfm->frontmatter_hashref; print qq(This is $metadata->{title}\n); print qq(This is $metadata->{date}\n); print qq(This is $metadata->{taxonomy}->{category}\n); print qq(This is $metadata->{taxonomy}->{tag}\n);
--- title: London Industry at Night date: 13:34 06/07/2014 taxonomy: category: blog tag: [city, night, photography] ---
正規表現
- $yf =~/^-{3}${1}(.*?)-{3}${1}/#Triple-dashedを含まない
- $yf =~/^(-{3}${1}.*?-{3})${1}/#Triple-dashedを含む