HTML::...:Common(3pm)
π NAME π
HTML::Display::Common β routines common to all HTML::Display subclasses π«Ά
Yep bestie, this is the HTML::...:Common(3pm) page, straight outta User Contributed Perl Documentation, and it's short because it's literally just the shared glue every subclass gets to inherit. Here's the whole vibe β¨
πΈ __PACKAGE__->new %ARGS πΈ
okay SO. This creates a brand-new object, and the object is justβ¦ a blessed hash π The arguments you pass in get stored right there inside that hash. That's the entire constructor, no cap.
But listen β if your own subclass constructor needs to do other stuff, you still have to call this constructor too, or it all falls apart π Like this:
package HTML::Display::WhizBang;
use parent 'HTML::Display::Common';
sub new {
my ($class) = shift;
my %args = @_;
my $self = $class->SUPER::new(%args);
# do stuff
$self;
};
See how it hits that $class->SUPER::new(%args) before doing its own little thing? That's the move. And the example bottoms out on a lone $self;, just saying π
β¨ $display->display %ARGS β¨
This is the routine that actually puts the HTML in front of your user's eyeballs π It takes these parameters:
html => SCALARβ a scalar holding the HTML πfile => SCALARβ a scalar holding the filename of the file to be displayed πbase =>β an optional base url for the HTML, so that relative links still work π¦locationβ synonymous tobaseπ
Basic usage, the moment you've all been waiting for:
my $html = "<html><body><h1>Hello world!</h1></body></html>";
my $browser = HTML::Display->new();
$browser->display( html => $html );
π Location parameter π
Okay picture this: you fetched a page from a remote site but you still want to display it to the user. That is exactly the situation where the location parameter comes in very handy π«Ά
my $html = '<html><body><img src="/images/hp0.gif"></body></html>';
my $browser = HTML::Display->new();
# This will display part of the Google logo
$browser->display( html => $html, base => 'http://www.google.com' );
And yes, the example uses base => right after telling you location is synonymous β it's giving "same thing, two names", and honestly? We love that for it π
π AUTHOR π
Copyright (c) 2004-2013 Max Maischein "<corion@cpan.org>" β absolute icon, thank you for your service π«‘
π LICENSE π
This module is released under the same terms as Perl itself. Periodt. π
and that's the whole page, bestie!! This was HTML::...:Common(3pm) from the User Contributed Perl Documentation, generated for perl v5.36.0 on 2022-10-15 β go forth and display some HTML, you 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