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
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 | |
by wazoox (Prior) on May 04, 2005 at 10:27 UTC | |
by suntech (Initiate) on May 04, 2005 at 10:39 UTC | |
by gellyfish (Monsignor) on May 04, 2005 at 10:43 UTC | |
by suntech (Initiate) on May 04, 2005 at 10:59 UTC | |
|