You really should look into Templating Solutions. Here are two for your amusement:
  1. Template:
    #!/usr/bin/perl -T use strict; use warnings; use CGI; use LWP::Simple; use Template; my $cgi = CGI->new; print $cgi->header; my $source; if ($cgi->param('fetch')) { $source = LWP::Simple::get($cgi->param('url')); } my $template = Template->new({ INCLUDE_PATH => '/usr/local/tt2/templates' }); $template->process(\*DATA, {cgi => $cgi, source => $source}); __DATA__ [% WRAPPER html/page html.head.title = 'view source' %] <form method="POST"> Enter URL: [% cgi.textfield('url') %] <p>[% cgi.submit('fetch') %]</p> </form> [% IF source %] <hr/> <pre>[% FILTER html %][% source %][% END %]</pre> <hr/> [% END %] [% END %]
  2. HTML::Template:
    #!/usr/bin/perl -T use strict; use warnings; use CGI; use LWP::Simple; use HTML::Template; my $cgi = CGI->new; my $template = HTML::Template->new( filehandle => \*DATA, associate => $cgi, ); if ($cgi->param('fetch')) { $template->param(source => LWP::Simple::get($cgi->param('url'))); } print $cgi->header, $template->output; __DATA__ <html> <head> <title>view source</title> </head> <body> <form method="POST"> Enter URL: <input type="text" name="url"/> <p><input type="submit" name="fetch" value="fetch"/></p> </form> <tmpl_if source> <hr/> <pre><tmpl_var name="source" escape="HTML"></pre> <hr/> </tmpl_if> </body> </html>
Feel free to ask questions about these modules, they are designed to make your life easier - but you don't appreciate that up front. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to 2Re: View The HTML ??? by jeffa
in thread View The HTML ??? by einerwitzen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.