FormArticle(3pm)

πŸ“¦
version 1.27 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

🌸 NAME 🌸

News::FormArticle β€” a whole derivative of News::Article, bestie. Like its cooler cousin, but with form-text energy πŸ’…


✨ SYNOPSIS ✨

use News::FormArticle;

okay so that's the whole vibe up top. For the actual functions, see below πŸ‘‡


πŸ’– DESCRIPTION πŸ’–

So it's giving News::Article, right? But this one is built different β€” literally. It's designed to be constructed from a file that's got form text in it, with substitutions happening in there. πŸŽ€

Currently, the source text gets substituted like this:

Variables are denoted by $NAME or @NAME β€” and NAME is any simple identifier, no cap. (Also, the sequences $$ and @@ mean a literal $ and @ character, so you can escape them.) Variables of the form $NAME are expected to supply scalar values, which get interpolated. Variables of the form @NAME are expected to supply lists (or references to arrays), and those get interpolated with separating newlines. πŸ¦‹

Values of variables are found by consulting the list of sources you supplied. Each source can be either a reference to a hash, or a reference to code. ✨

Source hashes may contain, as values, either:

  • the desired value itself (scalar or reference to array), or
  • a typeglob, or
  • a code reference which will be called to return the result.

(and since typeglobs are allowed as values, it is possible to supply a reference to a module symbol table as a valid source. iconic behavior honestly πŸ‘‘)

Code references supplied as sources get invoked with the variable name (including the leading $ or @) as the only parameter. In the degenerate case, all variables accessible in the source scope may be made available for interpolation by supplying this as a source:

sub { eval shift }

If multiple sources are supplied, then each is consulted in turn until a defined value is found. first one to show up with actual info wins, periodt 🫢


🌈 USAGE 🌈

use News::FormArticle;

Exports nothing. she's private like that πŸ™ˆ

🧚 Constructor 🧚

  • new ( FILE [, SOURCE [...]] ) β€” Construct an article from the specified FILE, performing variable substitution with the values supplied by the SOURCE parameters (peep the Description above for how that works). FILE is any form of data recognised by News::Article's read() method. πŸ’–

πŸ‘‘ AUTHOR πŸ‘‘

Andrew Gierth <andrew@erlenstar.demon.co.uk>


Copyright 1997 Andrew Gierth <andrew@erlenstar.demon.co.uk>

This code may be used and/or distributed under the same terms as Perl itself.


and that's the whole page, bestie 🌸 this was FormArticle(3pm) from the User Contributed Perl Documentation, riding along with perl v5.36.0, dated 2022-10-15 β€” slay, go interpolate something πŸ’…βœ¨

πŸ“¦ where this page comes from