Solved

Modify An HTML using Perl

Posted on 1998-09-25
4
245 Views
Last Modified: 2010-03-05
I want to ask about how to modify a html using CGI script
(PERL).
I use this to create a CGI Script that can modify name, address, and the comment from a guestbook html file?
How we can load the name, address, comment to our script and
we modify it?
0
Comment
Question by:ichen
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
zhongbing earned 20 total points
ID: 1205003
if i got all your idea then:
1. write a html with a form with the fields you need: name, address, and comment all anything else. the form's action should be the name of your perl excutable file.
2. the perl script get all the parameter, then instead of modify a html, if should totally wirte a new html file to stdout. it means the perl script create a new html and send it to stdout, the user's brower will get the html.

3 the html example (which have a filed name and message):

<head>
<title> post a message </title>
</head>
<body>
<form method="get"  action="http://sac.uky.edu/cgi-bin/cgiwrap/~jcao0/zh.pl">
<P><input type="text" name="name" size="20">
<P> message: <textarea name="message" cols=30 rows=4></textarea>
<P>
<input type="submit" value="submit">
<input type="reset" value="reset">
<form>
</html>
4 perl cgi example(it get the name and message value then wirte it to new html):
#! /usr/bin/perl
$|=1;
print "Content-type:text/html\n\n";
#print "test perl\n";
 
$buffer=$ENV{'QUERY_STRING'};
 
print"$buffer";
 
@pairs=split(/&/, $buffer);
foreach $pair(@pairs){
        ($name, $value)=split(/=/,$pair);
        $value=~tr/+/ /;
$value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
        $form{$name}=$value;
}
print"<title> message board </title>";
print"<h1> message board </h1>";
print"<p> name : $form{'name'}";
print"<p> message : $form{'message'}";
0
 
LVL 1

Author Comment

by:ichen
ID: 1205004
Can I use the perl script  to modify the name, address and comment?
0
 
LVL 1

Author Comment

by:ichen
ID: 1205005
Can I use the perl script  to modify the name, address and comment?
0
 

Expert Comment

by:mazares
ID: 1205006
I use a much simpler method for this kind of situation. I have the "shell" of the html document already present -- in his case, a guestbook form. I place "flags" such as <!put_id_here> in the html document. Then, my script opens the html file, reads it in as STDIN, outputting it a line at a time. If the script encounters the <!flag>, it then outputs the unique information (in html format) required by the particular flag's location in the document. Thus, the resulting html document is customized according to the user, the user's request, or whatever.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Input from stdin for perl 6 118
Existing perl code to be changed for ftp to sftp handling 14 162
PERL get the value for query 4 145
Removing file extension within a file. 4 90
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now