Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I realize you're just trying to be helpful, but I can't help but think code handouts like this harm a programmer learning perl in the medium term.

What is a new programmer more likely to do:

  • Copy and paste this minimally functional templatting system that kinda works, or
  • Do the ultimately more productive thing and learn how to install and use modules from CPAN.

Most newer programmers will probably choose the first, lesser productive route (but you know what they say about assumptions).

Just saying. A nudge to use something like HTML::Template with some sample code would probably be more helpful over the long term.

Here's something I whipped up to demonstrate some of what HTML::Template can do.

#!/usr/bin/perl use warnings; use strict; use HTML::Template; use CGI qw/:standard/; print header(); my $template=HTML::Template->new(filehandle=>*DATA,die_on_bad_params=> +1); my @count; foreach(1..10){ my %hash; $hash{NUMBER}=$_; push @count,\%hash; } $template->param( HEAD_TITLE=>'Test HTML::Template Page', PAGE_TITLE=>'This is a test HTML page.', CONTENT=>'Here is some sample content', COUNT=>\@count ); print $template->output; __DATA__ <html> <title><!-- TMPL_VAR HEAD_TITLE ESCAPE=HTML --></title> </html> <body> <h1><!-- TMPL_VAR PAGE_TITLE ESCAPE=HTML --></h1> <p><!-- TMPL_VAR CONTENT ESCAPE=HTML --></p> <p>I can count!</p> <ul> <!-- TMPL_LOOP COUNT --> <li><!-- TMPL_VAR NUMBER --></li> <!-- /TMPL_LOOP --> </ul> </body> </html>

-Any sufficiently advanced technology is
indistinguishable from doubletalk.

My Biz


In reply to Re^2: Pass the value from perl script to html page by Hero Zzyzzx
in thread Pass the value from perl script to html page by suntech

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-16 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found