Output(3pm)

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

✨ NAME ✨

SGMLS::Output β€” stack-based output procedures, bestie πŸ’… (yes this is the Output(3pm) page, we're doing this)


πŸŽ€ SYNOPSIS πŸŽ€

First things first, load the vibes:

  use SGMLS::Output;

Wanna print a string to wherever the current output destination is? Say less:

  output($data);

Wanna push a brand new output level onto the filehandle DATA:

  push_output('handle',DATA);

Wanna push a new output level onto the file "foo.data" (which opens and closes itself automatically, self-care king):

  push_output('file','foo.data');

Wanna push a new output level to a pipe running the shell command "sort":

  push_output('pipe','sort');

Wanna push a new output level that appends to the file "foo.data":

  push_output('append','foo.data');

Wanna push a new output level to an empty string:

  push_output('string');

Wanna push a new output level that appends to the string "David is ":

  push_output('string',"David is ");

Wanna push a new output level to The Great Beyond πŸ•³οΈ (literally, the void):

  push_output('nul');

Wanna go back to the previous output level:

  pop_output();

Wanna go back to the previous output level and get handed the contents of an output string:

  $data = pop_output();

🌈 DESCRIPTION 🌈

Okay so this library gives you redirectable, stack-based output β€” to files, pipes, handles, strings, or nul. Sounds niche, right? It's iconic actually. It's especially useful for packages like SGMLS, because handlers for individual SGML elements can temporarily switch up the default output destination and then restore it. And it's particularly useful for capturing the contents of an element (plus all its sub-elements) into a string. Sneaky, but make it fashion. πŸ’…

Example:

  sgmls('<title>', sub{ push_output('string'); });
  sgmls('</title>', sub{ $title = pop_output(); });

In between those two, literally anything sent to output (CDATA, bestie, CDATA) gets accumulated into the string that comes back out of pop_output().

Example:

  sgmls('<tei.header>', sub { push_output('nul'); });
  sgmls('</tei.header>', sub { pop_output(); });

Everything gets ignored until the header has finished. It's giving selective hearing. πŸ™ˆ


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: πŸ’–

SGMLS.


and that's the whole page, no crumbs left 🫢 this was perl v5.36.0, dated 2022-10-13, and it's the Output(3pm) page β€” periodt. bye bestie! πŸ’œβœ¨

πŸ“¦ where this page comes from