Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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. ;)


(the triplet paradiddle with high-hat)

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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-06-16 00:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.