PFT::Header(3)
π NAME π
PFT::Header β bestie, it's the header for PFT content textfiles. That's the whole vibe. It's a chunk of meta-info that sits at the top of your text and tells everyone what's inside. π
β¨ SYNOPSIS β¨
okay so here's how you actually use it, no cap:
use PFT::Header;
my $hdr = PFT::Header->new(
title => $title, # mandatory (conditions apply)
slug => $slug, # optional short identifier
date => $date, # optional (conditions apply) PFT::Date
author => $author, # optional
tags => $tags, # list of decoded strins, defaults to []
opts => $opts, # ignored by internals, defaults to {}
);
my $hdr = PFT::Header->load(\*STDIN);
my $hdr = PFT::Header->load('/path/to/file');
like. three whole ways to get a header. iconic. π
πΈ DESCRIPTION πΈ
A header is a chunk of meta-information describing content properties. It's giving little name tag but for a file. π·οΈ
It gets used inside a PFT::Tree::Content structure as the index for retrieving the content on the filesystem. And every textual content (i.e. PFT::Content::Entry) stores a textual representation of a header at the beginning of the file. So the header is literally living at the top of the file, main character energy fr fr. π
π§ Structure
Every content has:
- a title
- an optional author
- an optional list of tags, in the form of strings
- an optional hash
optsholding other options
π Textual representation
The textual representation of a header starts with a valid YAML document β and yes that includes the leading --- line β and it ends with another --- line. Bookends. We love a symmetrical moment. β¨
π οΈ Construction
You can build a header in three ways, and they match the three forms up in the SYNOPSIS. Cute, right?
The first form is constructed in code. The title field is mandatory unless there's a date field, and that date represents a month (i.e. it lacks the day field). This property is enforced by the constructor β like, it will not let you slide, bestie. π¨
The second and third forms are equivalent to each other. The only difference is where the header gets loaded from: a stream, or a file path, respectively. π«Ά
π Functions
These functions are not associated with an instance, so you call them like PFT::Header::function(...). Standing on their own. Independent. πββοΈ
slugifyβ given a string, it constructs a slug, which is a simplified version of that string.
(TODO: better describe it, also w.r.t. Unicode)
π Properties
Here's the full list, bestie, all of them:
$hdr->title
$hdr->author
$hdr->template
$hdr->tags
$hdr->date
$hdr->opts
$hdr->slug
$hdr->tags_slug
Now the breakdown:
titleβ returns the title of the content. Outputs a decoded string. β¨authorβ returns the author of the content, orundefif there is no author. Outputs a decoded string.tagsβ a list of tags declared by the header. These tags are in a normal (i.e. not slugified) form. Want the slugified version? Use the"tags_slug"method. π·οΈdateβ the date declared by the header, as aPFT::Dateobject. πoptsβ a list of options for this content.slugβ a slug of the title.tags_slugβ a list of tags, same as the"tags"method, but in slugified form.
π Methods
set_dateβ the setter fordate. The parameter must be aPFT::Dateobject. No substitutions, bestie. πdumpβ dumps the header onto a file. AGLOBorIO::Fileis expected as the argument. ποΈ
and that's the whole page, you ate it, no crumbs π
This little gem is perl v5.42.0 flavoured and it was dated 2025-07-25. Go forth and header responsibly, queen. πβ¨π¦
π¦ where this page comes from
- fedora 43: perl-PFT 1.4.1-18.fc43 Β· GPL-3.0-or-later
- fedora 44: perl-PFT 1.4.1-18.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms