HTML::Native::Literal - literal text to be included within HTML
use HTML::Native::Literal; my $literal = HTML::Native::Literal->new ( "<p>Hello</p>" ); print $literal; # prints "<p>Hello</p>"
An HTML::Native::Literal object represents a piece of text to be included within an HTML::Native tree without being subject to entity encoding.
You can use an HTML::Native::Literal object when you have some pre-existing HTML code that you want to include verbatim within an HTML::Native tree.
$literal = HTML::Native::Literal->new ( <text> ); $literal = HTML::Native::Literal->new ( \<text> );
Create a new HTML::Native::Literal object, representing some literal text to be included within an HTML document. For example:
my $literal = HTML::Native::Literal->new ( "<p>Hello</p>" ) print $literal; # prints "<p>Hello</p>"
or
my $elem = HTML::Native->new ( div => [ h1 => "Welcome" ], HTML::Native::Literal->new ( "<p>Hello</p>" ) ); print $elem; # prints "<div><h1>Welcome</h1><p>Hello</p></div>"
If you pass a reference to a scalar variable, then the HTML::Native::Literal object will remain associated with the original variable. For example:
my $text = "<p>Hello</p>"; my $elem = HTML::Native->new ( div => [ h1 => "Welcome" ], HTML::Native::Literal->new ( \$text ), ); print $elem; # prints "<div><h1>Welcome</h1><p>Hello</p></div>" $text = "<p>Goodbye</p>"; print $elem; # now prints "<div><h1>Welcome</h1><p>Goodbye</p></div>"
To install HTML::Native, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::Native
CPAN shell
perl -MCPAN -e shell install HTML::Native
For more information on module installation, please visit the detailed CPAN module installation guide.