.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Data::Phrasebook::Loader::Text 3pm" .TH Data::Phrasebook::Loader::Text 3pm "2022-11-19" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Data::Phrasebook::Loader::Text \- Absract your phrases with plain text files. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Data::Phrasebook; \& \& my $q = Data::Phrasebook\->new( \& class => \*(AqFnerk\*(Aq, \& loader => \*(AqText\*(Aq, \& file => \*(Aqphrases.txt\*(Aq, \& ); \& \& # use default delimiters (:variable) \& my $phrase = $q\->fetch($keyword,{variable => \*(Aqsubstitute\*(Aq}); \& \& # use Template Toolkit style delimiters \& $q\->delimiters( qr{ \e[% \es* (\ew+) \es* %\e] }x ); \& my $phrase = $q\->fetch($keyword,{variable => \*(Aqsubstitute\*(Aq}); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This loader plugin implements phrasebook patterns using plain text files. .PP Phrases can be contained within one or more dictionaries, with each phrase accessible via a unique key. Phrases may contain placeholders, please see Data::Phrasebook for an explanation of how to use these. Groups of phrases are kept in a dictionary. In this implementation a single file is one complete dictionary. .PP An example plain text file: .PP .Vb 1 \& foo=Welcome to :my world. It is a nice :place. .Ve .PP Within the phrase text placeholders can be used, which are then replaced with the appropriate values once the \fBget()\fR method is called. The default style of placeholders can be altered using the \fBdelimiters()\fR method. .SH "INHERITANCE" .IX Header "INHERITANCE" Data::Phrasebook::Loader::Text inherits from the base class Data::Phrasebook::Loader::Base. See that module for other available methods and documentation. .SH "METHODS" .IX Header "METHODS" .SS "load" .IX Subsection "load" Given a \f(CW\*(C`file\*(C'\fR, load it. \f(CW\*(C`file\*(C'\fR must contain a valid phrase map. .PP .Vb 2 \& my $file = \*(Aqenglish.txt\*(Aq; \& $loader\->load( $file ); .Ve .PP This method is used internally by Data::Phrasebook::Generic's \&\f(CW\*(C`data\*(C'\fR method, to initialise the data store. .PP To utilise the dictionary framework for a Plain Text phrasebook, the idea is to use a directory of files, where the directory is passed via the \f(CW\*(C`file\*(C'\fR argument and the dictionary, the specific name of the file, is passed via the \f(CW\*(C`dictionary\*(C'\fR argument. .PP .Vb 3 \& my $file = \*(Aq/tmp/phrasebooks\*(Aq; \& my $dictionary = \*(Aqenglish.txt\*(Aq; \& $loader\->load( $file, $dictionary ); .Ve .SS "get" .IX Subsection "get" Returns the phrase stored in the phrasebook, for a given keyword. .PP .Vb 1 \& my $value = $loader\->get( $key ); .Ve .SS "dicts" .IX Subsection "dicts" Having instantiated the \f(CW\*(C`Data::Phrasebook\*(C'\fR object class, and using the \f(CW\*(C`file\*(C'\fR attribute as a directory path, the object can return a list of the current dictionaries available as: .PP .Vb 4 \& my $pb = Data::Phrasebook\->new( \& loader => \*(AqText\*(Aq, \& file => \*(Aq/tmp/phrasebooks\*(Aq, \& ); \& \& my @dicts = $pb\->dicts; .Ve .PP or .PP .Vb 1 \& my @dicts = $pb\->dicts( $path ); .Ve .SS "keywords" .IX Subsection "keywords" Having instantiated the \f(CW\*(C`Data::Phrasebook\*(C'\fR object class, using the \f(CW\*(C`file\*(C'\fR and \f(CW\*(C`dict\*(C'\fR attributes as required, the object can return a list of the current keywords available as: .PP .Vb 5 \& my $pb = Data::Phrasebook\->new( \& loader => \*(AqText\*(Aq, \& file => \*(Aq/tmp/phrasebooks\*(Aq, \& dict => \*(AqTEST\*(Aq, \& ); \& \& my @keywords = $pb\->keywords; .Ve .PP or .PP .Vb 1 \& my @keywords = $pb\->keywords( $path, $dict ); .Ve .PP Note that \f(CW$path\fR can either be the directory path, where \f(CW$dict\fR must be the specific file name of the dictionary, or the full path of the dictionary file. .PP In the second instance, the function will not load a dictionary, but can be used to interrogate the contents of a known dictionary. .SH "SEE ALSO" .IX Header "SEE ALSO" Data::Phrasebook. .SH "SUPPORT" .IX Header "SUPPORT" Please see the \s-1README\s0 file. .SH "AUTHOR" .IX Header "AUTHOR" .Vb 2 \& Barbie, \& for Miss Barbell Productions . .Ve .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" .Vb 1 \& 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. .Ve