You're using what's called a template. You can do by hand something like this:

here's the html file, let's call it "test.html":

<html> <body> %MESSAGE% </body> </html>

here's the perl script

#!/usr/bin/perl -w use strict; open HTML, "test.html" or die "can't open html file!\n"; # read the whole file in a variable my $htmldata=join '', <HTML>; close HTML; # prepare the message to display my $parameter=shift; my $message; if ($parameter >0) { $message="Oh no!"} elsif ($parameter<0) { $message="Really?"} else {$message="Mwahahahaha!"} # replace %MESSAGE% by whatever you want $htmldata =~ s/\%MESSAGE%/$message/; # display the modified html print $htmldata

Try running this script with a parameter like 0, 3, -5 and see what's happening.

of course that's really the quick n' dirty way. The Right Way is to use appropriate modules : CGI to manage the input/output from/to the web server, and HTML::Template to manage the HTML templating.


In reply to Re^3: Pass the value from perl script to html page by wazoox
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":



  • 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.