SGMLS::Refs(3pm)

SGMLS::Refs3pm

Forward reference handling

Usage

  use SGMLS::Refs;

To create a new reference-manager object using the file "foo.refs":

  my $refs = new SGMLS::Refs("foo.refs");

To create a new reference-manager object using the file "foo.refs" and logging changes to the file "foo.log":

  my $refs = new SGMLS::Refs("foo.refs","foo.log");

To record a reference:

  $refs->put("document title",$title);

To retrieve a reference:

  $title = $refs->get("document title");

To return the number of references changed since the last run:

  $num = $refs->changed;

To print a LaTeX-like warning if any references have changed:

  $refs->warn;

Overview

This library can be used together with the SGMLS package to keep track of forward references from one run to another, like the LaTeX ".aux" files. Each reference manager is an object which reads and then rewrites a file of perl source, with the file name provided by the caller.

Example:

  # 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);
  });

See also:

SGMLS, SGMLS::Output.

Releases

14 releases since Debian 2.2 (Potato); the text changed 7 times.

  1. 2.2
  2. 3.0
  3. 3.1–4.0
  4. 5.0–7
  5. 8
  6. 9–11
  7. 12–13
  8. Arch

From perl-sgmls 1:1.1-14 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.