in reply to Re^2: Pass the value from perl script to html page
in thread Pass the value from perl script to html page

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.

Replies are listed 'Best First'.
Re^4: Pass the value from perl script to html page
by suntech (Initiate) on May 04, 2005 at 10:22 UTC
    Hi, Thaks for your reply, its still not clear let me explain more clearly, I am validating the values of html form called mypage.htm in perl script myscript.pl, whatI need to do is if name filed or date of birht field is empty then just pass the error messsage to html page mypage.htm, I just dont know how to pass the value form perl script to html page, I can pass the values from html page to perl script.
      You just have to process the html page THRU the perl script, don't display the html directly. Exactly like in the example I wrote...
        ....:-( but I have done lot of work on it, can I use the same one or I will have to start from scratch.