Data::...::Plain(3pm)

πŸ“¦
version 0.35 Β· 2 versions
  • 0.35 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.35 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Data::...::Plain(3pm) πŸ’–

okay bestie, this is a page from the User Contributed Perl Documentation β€” yes it literally has the dots in the name, that's not a typo, that's the actual module title, slay. it's Data::...::Plain, and it's giving "small but mighty" energy. let's get into it 🫢


✨ NAME ✨

Data::Phrasebook::Plain β€” The Simple Phrasebook Model. no cap, that's the whole vibe: simple. πŸ’…


🌸 SYNOPSIS 🌸

here's how you actually use it, copy-paste ready:

use Data::Phrasebook;

my $q = Data::Phrasebook->new(
    class  => 'Plain',
    loader => 'Text',
    file   => 'phrases.txt',
);

my $r = Data::Phrasebook->new( file => 'phrases.txt' );

# simple keyword to phrase mapping
my $phrase = $q->fetch($keyword);

# keyword to phrase mapping with parameters
$q->delimiters( qr{ \[% \s* (\w+) \s* %\] }x );
my $phrase = $q->fetch($keyword,{this => 'that'});

see how class => 'Plain' is just... sitting there? iconic. also yes, you can totally skip the whole config hash and just do Data::Phrasebook->new( file => 'phrases.txt' ), because defaults are a thing and they love you. πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so this module is the fallback class, the default one, the main character who shows up when nobody else was specified. it doesn't do a whole lot β€” and honestly? that's the point. it acts as a very simple templating facility, and it does that one job with zero drama. no bells, no whistles, just vibes. ✨


πŸ‘‘ METHODS πŸ‘‘

πŸŽ€ fetch

it retrieves the specified "template" and substitutes any "keywords" for "values". that's it. that's the method. and it ate. πŸ’…

so like, given this line:

hello=Hello [% where %]!

and this code:

my $text = $q->fetch( 'hello', {
    where => 'world'
} );

the return value is:

Hello world!

literally magic, except it's just string substitution and we love her for it. 🌈

fun fact bestie: the delimiters are deliberately taken from Template Toolkit. not an accident, not a coincidence β€” a choice. iykyk. 🧚

πŸ’œ SEE ALSO πŸ’œ

  • Data::Phrasebook
  • Data::Phrasebook::Generic

go read those too, they're the extended universe. πŸ“š


🌟 SUPPORT 🌟

Please see the README file. (short king energy, but fr, the README has the answers.) πŸ™ˆ


🌸 AUTHOR 🌸

  • Original author: Iain Campbell Truskett (16.07.1979 - 29.12.2003)
  • Maintainer: Barbie <barbie@cpan.org> since January 2004.
  • for Miss Barbell Productions <http://www.missbarbell.co.uk>.

rest in peace Iain, and thank you Barbie for keeping this whole thing alive for actual decades. πŸ«ΆπŸ’–


  • Copyright (C) 2003 Iain Truskett.
  • Copyright (C) 2004-2013 Barbie for Miss Barbell Productions.

This distribution is free software; you can redistribute it and/or modify it under the Artistic License v2.


okay that's the whole page, you're officially caught up. this was perl v5.36.0, dated 2022-11-19, and it's the Data::...::Plain(3pm) manual page. go forth and template responsibly, bestie πŸ’…βœ¨πŸŽ€