Refs(3pm)
π SGMLS::Refs β forward reference handling, but make it cute β¨
okay bestie, so <pink>SGMLS::Refs</pink> is the module you call when you want your forward references to remember themselves between runs. it's giving LaTeX .aux files, but make it Perl. no cap. π
β¨ SYNOPSIS β¨
first things first, you gotta pull it in:
use SGMLS::Refs;
wanna spin up a brand new reference-manager object using the file "foo.refs"? bet:
my $refs = new SGMLS::Refs("foo.refs");
wanna do that and also log every change into "foo.log"? slay:
my $refs = new SGMLS::Refs("foo.refs","foo.log");
recording a reference? literally just:
$refs->put("document title",$title);
getting one back? easy:
$title = $refs->get("document title");
want the count of how many references changed since the last run? iconic:
$num = $refs->changed;
and if you want it to scream a LaTeX-ish warning whenever references have changed:
$refs->warn;
periodt. π
πΈ DESCRIPTION πΈ
so this library is meant to vibe alongside the SGMLS package and keep track of forward references from one run to the next β exactly like those LaTeX .aux files do. each reference manager is its own object, and it reads a file of perl source and then rewrites it, with the file name handed to it by the caller. iykyk. π¦
here's the whole flow, in example form:
# Start up the reference manager before the parse.
sgml('start', sub { $refs = new SGMLS::Refs("foo.refs"); });
# Warn about any changed references at the end.
sgml('end', sub { $refs->warn; });
# Look up the title from the last parse, if available.
sgml('<div>', sub {
my $element = shift;
my $id = $element->attribute(ID)->value;
my $title = $refs->get("title:$id") || "[no title available]";
$current_div_id = $id;
output "\\section{$title}\n\n";
});
# Save the title for the next parse.
sgml('<head>', sub { push_output('string'); });
sgml('</head>', sub {
my $title = pop_output();
my $id = $current_div_id;
$refs->put("title:$id",$title);
});
look at that. main character parser energy. π
π AUTHOR AND COPYRIGHT π
Copyright 1994 and 1995 by David Megginson, "dmeggins@aix1.uottawa.ca". π
Distributed under the terms of the Gnu General Public License (version 2, 1991) β see the file "COPYING" which is included in the SGMLS.pm distribution.
π SEE ALSO: π
SGMLSSGMLS::Output
and that's the whole page, bestie π«Ά this was the User Contributed Perl Documentation version of Refs(3pm), perl v5.36.0, dated 2022-10-13. go forth and forward-reference responsibly β¨ππ
π¦ where this page comes from
- ubuntu noble: libsgmls-perl 1.03ii-38 Β· GPL-2.0-or-later
- ubuntu resolute: libsgmls-perl 1.03ii-38 Β· GPL-2.0-or-later
- ubuntu stonking: libsgmls-perl 1.03ii-38 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms