「Text::FrontMatter::YAML」の版間の差分

提供: dsk's note
移動: 案内検索
16行目: 16行目:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
<pre>
 +
---
 +
title: London Industry at Night
 +
date: 13:34 06/07/2014
 +
taxonomy:
 +
    category: blog
 +
    tag: [city, night, photography]
 +
---
 +
</pre>
 
[[Category: perl]]
 
[[Category: perl]]

2015年5月2日 (土) 08:15時点における版

#!/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);
---
title: London Industry at Night
date: 13:34 06/07/2014 
taxonomy:
    category: blog
    tag: [city, night, photography]
---