HTML::Display(3pm)
π HTML::Display β bestie edition π
okay so this is HTML::Display, a User Contributed Perl Documentation page, and honestly? she's a baddie. she shows HTML to your user in a browser, and you don't even have to think about which browser. iconic. π
β¨ NAME β¨
HTML::Display β display HTML locally in a browser π¦
πΈ SYNOPSIS πΈ
use strict;
use HTML::Display;
# guess the best value from $ENV{PERL_HTML_DISPLAY_CLASS}
# or $ENV{PERL_HTML_DISPLAY_COMMAND}
# or the operating system, in that order
my $browser = HTML::Display->new();
warn "# Displaying HTML using " . ref $browser;
my $location = "http://www.google.com/";
$browser->display(html => $html, location => $location);
# Or, for a one-off job :
display("<html><body><h1>Hello world!</h1></body></html>");
so basically: either you build a whole lil browser object and keep it around, or for a one-off job you just call display(...) and vibe. your call, bestie π«Ά
π DESCRIPTION π
This module abstracts the task of displaying HTML to the user. The displaying is done by launching a browser and navigating it to either a temporary file with the HTML stored in it, or, if possible, by pushing the HTML directly into the browser window.
Translation: you hand it HTML, it makes a browser show that HTML. If it can push the HTML straight into the window it does that; otherwise it writes a temp file with the HTML in it and points the browser there. no cap. π₯
The module tries to automagically select the "correct" browser, but if it dosen't find a good browser, you can modify the behaviour by setting some environment variables :
PERL_HTML_DISPLAY_CLASS
If HTML::Display already provides a class for the browser you want to use, setting PERL_HTML_DISPLAY_CLASS to the name of the class will make HTML::Display use that class instead of what it detects.
PERL_HTML_DISPLAY_COMMAND
If there is no specialized class yet, but your browser can be controlled via the command line, then setting PERL_HTML_DISPLAY_COMMAND to the string to navigate to the URL will make HTML::Display use a system() call to the string. A %s in the value will be replaced with the name of the temporary file containing the HTML to display.
so like β class first if we have one, command line second if we don't. and that %s? that's the placeholder where the temp-file name gets slotted in. don't forget her. π
π§ %HTML::Display::os_default π§
The hash %HTML::Display::os_default contains pairs of class names for the different operating systems and routines that test whether this script is currently running under it. If you you want to dynamically add a new class or replace a class (or the rule), modify %os_default :
# Install class for MagicOS
$HTML::Display::os_default{"HTML::Display::MagicOS"}
= sub { $^O =~ qr/magic/i };
it's giving "make your own OS entry" energy and honestly we love that for you β¨
π __PACKAGE__->new %ARGS and $browser->display( %ARGS ) π
Will display the HTML. The following arguments are valid :
baseβ Base to which all relative links will be resolvedhtmlβ Scalar containing the HTML to be displayedfileβ Scalar containing the name of the file to be displayed This file will possibly be copied into a temporary file!location(synonymous tobase)
β οΈ heads up: that file one might get copied into a temporary file. just so you know. π
If only one argument is passed, then it is taken as if
html => $_[0]
was passed.
so like, one arg = it's the html. periodt.
π EXPORTS π
The subroutine display is exported by default π
yes bestie, it just shows up in your namespace. that's the vibe.
π COMMAND LINE USAGE π
Display some HTML to the user :
perl -MHTML::Display -e "display '<html><body><h1>Hello world</body></html>'"
Display a web page to the user :
perl -MLWP::Simple -MHTML::Display -e "display get 'http://www.google.com'"
Display the same page with the images also working :
perl -MLWP::Simple -MHTML::Display -e "display html => get('http://www.google.com'),
location => 'http://www.google.com'"
see how the third one passes location too? that's how the relative links and images actually resolve. main character move. π
π AUTHOR π
Copyright (c) 2004-2007 Max Maischein <corion@cpan.org> π
π LICENSE π
This module is released under the same terms as Perl itself. π
okay that's the whole page bestie, you ate π
this gorgeous thing is perl v5.36.0, dated 2022-10-15, and it's HTML::Display(3pm) β go display some HTML, you've got this π¦β¨
π¦ where this page comes from
- ubuntu noble: libhtml-display-perl 0.40-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-display-perl 0.40-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-display-perl 0.40-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms