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

Hi Thanks both of you for your reply, actualy I have created a saperate html page now let say I want to diaplay tow differnt messages on that html page, say if conditon A is tru in perl script then messages A will be move to a field and pass to html page otherwise message B will be passed to html page. html page is seperate one, not creating in perl script.
  • Comment on Re^2: Pass the value from perl script to html page

Replies are listed 'Best First'.
Re^3: Pass the value from perl script to html page
by gellyfish (Monsignor) on May 04, 2005 at 10:02 UTC
Re^3: Pass the value from perl script to html page
by wazoox (Prior) on May 04, 2005 at 10:08 UTC
    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.

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