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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |