Reputation: 1361
Is there a function in PERL (don't care if it's a built-in function or a module-provided function) that will accept a string containing a section of HTML code as it's argument --- and as it's return value provide a string of newly-generated HTML code that, when sent to the browser, will show the user the same HTML code that originally was provided to this function as an argument?
For example, if the argument provided to this function is
<p>This is <em>really</em>
what I call "awesome" & then some.</p>
I would like the return-value to be something alone the lines of
<p>This is <em>really</em><br/>what
I call "awesome" & then some.</p>
So - does there exist a function in Perl that will do this for me?
Upvotes: 0
Views: 172
Reputation: 126722
Your best choice is probably the HTML::Escape
module
Use it like this
use strict;
use warnings 'all';
use HTML::Escape 'escape_html';
my $html = <<END_HTML;
<p>This is <em>really</em>
what I call "awesome" & then some.</p>
END_HTML
print escape_html($html);
<p>This is <em>really</em>
what I call "awesome" & then some.</p>
Upvotes: 1